Hi everyone
How do I solve for "compile error: For each control variable must be variant or object"? It then highlights "FilePath" which I made bold in my code below.
' Open file dialog to select multiple Excel files
Set FileDialog = Application.FileDialog(msoFileDialogFilePicker)
With FileDialog
.AllowMultiSelect = True
.Title = "Select Soccer Match Files"
.Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsm", 1
FileSelected = .Show
End With
If FileSelected Then
' Loop through each selected file
For Each FilePath In FileDialog.SelectedItems
' Open the source workbook
Workbooks.Open FilePath
Set wsSrc = ActiveWorkbook.Sheets(1) ' Assumes data is on the first sheet
How do I solve for "compile error: For each control variable must be variant or object"? It then highlights "FilePath" which I made bold in my code below.
' Open file dialog to select multiple Excel files
Set FileDialog = Application.FileDialog(msoFileDialogFilePicker)
With FileDialog
.AllowMultiSelect = True
.Title = "Select Soccer Match Files"
.Filters.Add "Excel Files", "*.xls; *.xlsx; *.xlsm", 1
FileSelected = .Show
End With
If FileSelected Then
' Loop through each selected file
For Each FilePath In FileDialog.SelectedItems
' Open the source workbook
Workbooks.Open FilePath
Set wsSrc = ActiveWorkbook.Sheets(1) ' Assumes data is on the first sheet