Try
Sub test()
Dim ws As Worksheet, a, i As Long, myName As String, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
Set ws = Sheets.Add
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)) = Empty
myName = a(i, 1) & "_" & Split(.Cells(i, 6).Value, ",")(0) & ".xlsx"
ws.Name = Split(.Cells(i, 1).Value, ",")(0)
ws.Cells.Clear
.AutoFilter 7, a(i, 1)
.Copy ws.Cells(1)
ws.Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & myName
ActiveWorkbook.Close False
.AutoFilter
End If
Next
End With
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Bookmarks