Give the procedure below a try. It works for me on a shortened sample size. Be sure that the "MyPath" line of the code matches your file path as far as the "Main" folder. Let me know how it goes...
Sub SaveByCoName()
Dim wbSource As Workbook
Dim MyPath As String
Dim wb As Workbook
Dim i As Long
Dim LastRow3 As Long, LastRow1 As Long
Dim UM As String
Dim ContName As String
Application.ScreenUpdating = False
MyPath = "C:\Desktop\Main\" 'MAKE SURE THIS MATCHES YOUR FILE PATH
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
Set wbSource = ActiveWorkbook
LastRow3 = wbSource.Sheets(3).Cells(Rows.Count, "B").End(xlUp).Row
LastRow1 = wbSource.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To LastRow3
UM = wbSource.Sheets(3).Range("B" & i).Value
ContName = wbSource.Sheets(3).Range("C" & i).Value
wbSource.Sheets(1).Cells.AutoFilter
With wbSource.Sheets(1).Range("A1:J" & LastRow1)
.AutoFilter
.AutoFilter Field:=10, Criteria1:=UM
.SpecialCells(xlCellTypeVisible).Copy
End With
Set wb = Workbooks.Add
wb.Sheets(1).Range("A1").PasteSpecial
wb.SaveAs (MyPath & UM & "\" & ContName & "\" & ContName & ".xlsx")
wb.Close
Next i
wbSource.Sheets(1).Cells.AutoFilter
Application.ScreenUpdating = True
End Sub
Bookmarks