I will sneak this one in for posterity..
Used a couple of methods straight from snb's site.. as you can probably see..
Private Sub CommandButton1_Click()
Dim a_sn, a_sp, X0, it, Z, c00, i As Long, ii As Long, cnt As Long
Application.ScreenUpdating = False
a_sn = Sheets("Input").Range("B7:G" & Range("B" & Rows.Count).End(xlUp).Row): cnt = 1
With CreateObject("scripting.dictionary")
For Each it In Application.Index(a_sn, 0, 6)
X0 = .Item(a_sn(cnt, 6)): cnt = cnt + 1
Next
Z = .keys
End With
For i = LBound(Z) To UBound(Z)
For ii = 1 To UBound(a_sn)
If a_sn(ii, 6) = Z(i) Then c00 = c00 & "_" & ii
Next ii
a_sp = Application.Index(a_sn, Application.Transpose(Split(Mid(c00, 2), "_")), Array(1, 2, 3, 4, 5, 6))
c00 = ""
Workbooks.Add
With ActiveWorkbook
.Sheets("Sheet1").Range("A1").Resize(1, 6).Value = Array("Depot Name", "Drop Account Code", "Drop Account Description", "Unit Sales (net of VAT)", "Total Accrued", "Name")
.Sheets("Sheet1").Range("A2").Resize(UBound(a_sp), 6).Value = a_sp
.Sheets("Sheet1").Columns.AutoFit
.SaveAs ThisWorkbook.Path & "\" & Z(i) & ".xls", FileFormat:=56
.Close 1
End With
Next i
Application.ScreenUpdating = True
End Sub
Bookmarks