Hi very new to VBA and coding so all help would be very appreciated.
So i have about 37 files which i need to open with VBA and then take some data and aggregate it into a summary however some of the files are password protected thankfully with the same password.
I am using the Application.Get Open file name to get the location of all the files and then usings a loop from 1 to n to open the FileNames(i) what can i do so that as the workbook is opened and it asks for the password it types in the password "password1".
Sub Aggregation_Data()
Dim FileNames As Variant, i As Integer, j As Integer
Dim TWB As Workbook, aWB As Workbook
Set TWB = ThisWorkbook
MsgBox ("Enter Files that you wish to import data from")
FileNames = Application.GetOpenFilename(FileFilter:="Excel Filter (*.xlsx), *xlsx", Title:="Open File(s)", MultiSelect:=True)
For i = 1 To UBound(FileNames)
Workbooks.Open FileNames(i)
Next i
End Sub
So i have about 37 files which i need to open with VBA and then take some data and aggregate it into a summary however some of the files are password protected thankfully with the same password.
I am using the Application.Get Open file name to get the location of all the files and then usings a loop from 1 to n to open the FileNames(i) what can i do so that as the workbook is opened and it asks for the password it types in the password "password1".
Sub Aggregation_Data()
Dim FileNames As Variant, i As Integer, j As Integer
Dim TWB As Workbook, aWB As Workbook
Set TWB = ThisWorkbook
MsgBox ("Enter Files that you wish to import data from")
FileNames = Application.GetOpenFilename(FileFilter:="Excel Filter (*.xlsx), *xlsx", Title:="Open File(s)", MultiSelect:=True)
For i = 1 To UBound(FileNames)
Workbooks.Open FileNames(i)
Next i
End Sub