I reused some of Jindon's code so hopefully it works the first time.
If you have any problems copy and paste the line of code that errors, it will be the one highlighted in yellow.
Try this on a copy.
Sub ImportWorksheets()
Dim ws As Worksheet, a, i As Long, myName As String, dic As Object, arrFiles, j, wbSrc As Workbook
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With Sheets("sheet1").Cells(1).CurrentRegion
a = .Columns("g").Value
For i = 2 To UBound(a, 1)
If Not dic.exists(a(i, 1)) Then
dic(a(i, 1)) = a(i, 1) & "_" & Split(.Cells(i, 6).Value, ",")(0) & ".xlsx"
End If
Next
arrFiles = dic.items()
For Each j In arrFiles
If Dir(ThisWorkbook.Path & "\" & j) <> "" Then
Set wbSrc = Workbooks.Open(ThisWorkbook.Path & "\" & j)
wbSrc.Worksheets(1).Copy After:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
wbSrc.Close
End If
Next j
End With
Application.ScreenUpdating = True
End Sub
Bookmarks