I have the below code that allows the user to 'FileDialogOpen' a varying list of Excel files from a predefined folder. This code works fine.
I need to add a Do/Loop or For/Next to process each file after they are all opened. I simply want to copy a Range of Cells from each of these files to the file that contains this code.
I'm pretty sure this will use an Array() but not sure how to do it. I can handle the CopyPaste code, just need the Array/Do/Loop portion.
VBA Code:
Dim wbThis As Workbook
Dim fName As String
Dim FileToOpen As String
Set wbThis = ThisWorkbook
fldrName = wbThis.Path & "\myFolder\"
ChDir fldrName
With Application.FileDialog(msoFileDialogOpen)
.Title = "Open 'ALL' Workbooks"
.InitialFileName = fldrName & "*.xls"
.AllowMultiSelect = True
.Filters.Clear
If .Show Then
'Display selected files
For i = 1 To .SelectedItems.Count
Workbooks.Open Filename:=.SelectedItems(i), ReadOnly:=False, Password:=""
ActiveWindow.WindowState = xlMaximized
Next
Else
MsgBox "No Comm w/b selected, please try again."
Application.DisplayAlerts = False
Application.Quit
Exit Sub
End If
End With
I need to add a Do/Loop or For/Next to process each file after they are all opened. I simply want to copy a Range of Cells from each of these files to the file that contains this code.
I'm pretty sure this will use an Array() but not sure how to do it. I can handle the CopyPaste code, just need the Array/Do/Loop portion.