Try this. It might be a start of what you're after.
You have to change all the references like sheet names ans cells ranges as required.
Sub Update_Summary()
Dim wb1 As Workbook, wbArr, myPath As String, wb2 As String, i As Long, file_Open As String
Application.ScreenUpdating = False
Set wb1 = ThisWorkbook '<----- The workbook with this code in it
wbArr = Range("I2:I" & Cells(Rows.Count, "I").End(xlUp).Row).Value '<----- Names of the files to be opened.
myPath = ChooseFolder() & "\"
MsgBox ("Please select Summary File")
wb2 = Application.GetOpenFilename()
Workbooks.Open (wb2), UpdateLinks:=0
wb2 = Dir(wb2, vbDirectory) '<----- Need Workbook name without the path
For i = LBound(wbArr) To UBound(wbArr) '<----- Go through all the workbooks one by one
file_Open = Dir(myPath & wbArr(i, 1) & ".xl*")
If Dir(myPath & wbArr(i, 1) & ".xl*") <> "" Then
Workbooks.Open myPath & file_Open
ActiveWorkbook.Sheets("Sheet1").Copy After:=Workbooks(wb2).Sheets(Sheets.Count) '<----- Here it copies Sheet1. Needs changing. Also change Sheets.Count
With ActiveSheet
.Name = wbArr(i, 1) & " " & i '<----- Might want to change the naming also
End With
Workbooks(file_Open).Close False
file_Open = Dir
End If
Next i
Application.ScreenUpdating = True
End Sub
Function ChooseFolder() As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "C:\"
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
ChooseFolder = sItem
Set fldr = Nothing
End Function
Bookmarks