Based on your pics.
Assuming the name of the source data sheet is "Sheet1" and the header starts from A1.
Sub test()
Dim a, e, x, myCode, i As Long, ii As Long, wb As Workbook, r As Range
Application.ScreenUpdating = False
Set wb = Workbooks.Add
With wb.Sheets(1)
.[a1] = "Shipment Info"
.[a3] = "Destination"
.[f3] = "Week:"
.[a5:c5] = [{"Product Code","Product Description","Amount"}]
End With
Set r = ThisWorkbook.Sheets("sheet1").Cells(1).CurrentRegion
myCode = r.Parent.[unique(filter(a2:b50000,(a2:a50000<>"")*(b2:b50000<>"")))]
For i = 1 To UBound(myCode, 1)
If (myCode(i, 1) <> "") * (myCode(i, 2) <> "") Then
For ii = 5 To r.Columns.Count
x = Filter(r.Parent.Evaluate("transpose(if((" & r.Columns(1).Address & _
"=" & myCode(i, 1) & ")*(" & r.Columns(ii).Address & _
"<>0),row(1:" & r.Rows.Count & ")))"), False, 0)
If UBound(x) > -1 Then
a = Application.Index(r.Value, Application.Transpose(x), Array(3, 4, ii))
With wb.Sheets(1)
.[b2:c2] = Application.Index(myCode, i, 0)
.[g3] = Trim$(Replace(r.Cells(1, ii), "Week", ""))
.[a5].CurrentRegion.Offset(1).ClearContents
.[a6].Resize(UBound(x) + 1, 3) = a
.Parent.SaveAs ThisWorkbook.Path & "\" & Join(Array(myCode(i, 1), _
myCode(i, 2), r.Cells(1, ii)), "_"), 51
End With
End If
Next
End If
Next
wb.Close False
Application.ScreenUpdating = True
End Sub
Bookmarks