Sub test()
Sheets("打印发货单").Cells.Clear
Set dNum = CreateObject("scripting.dictionary")
With Sheets("发货单明细")
LastRowA = .Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To LastRowA
Key = .Cells(i, 8).Value
dNum(Key) = ""
Next
arr = dNum.keys
'.Range("a12").Resize(1, UBound(arr) + 1) = arr
'.Range("a12").Resize(UBound(arr) + 1) = Application.Transpose(arr)
For i = 0 To UBound(arr)
Sheets("模板").[A3] = "客户:"
Sheets("模板").[c3] = ""
Sheets("模板").[f2] = ""
Sheets("模板").Range("A5:F14").ClearContents
k = 0
For j = 2 To LastRowA
If .Cells(j, 8) = arr(i) Then
Sheets("模板").[A3] = "客户:" & .Cells(j, 2)
Sheets("模板").[c3] = .Cells(j, 1)
Sheets("模板").[f2] = arr(i)
Sheets("模板").Cells(5 + k, 1) = .Cells(j, 3)
Sheets("模板").Cells(5 + k, 2) = .Cells(j, 4)
Sheets("模板").Cells(5 + k, 3) = .Cells(j, 5)
Sheets("模板").Cells(5 + k, 4) = .Cells(j, 6)
Sheets("模板").Cells(5 + k, 5) = .Cells(j, 7)
k = k + 1
End If
Next
Sheets("模板").Range("A1:g19").Copy
Sheets("打印发货单").Activate
Sheets("打印发货单").Cells(i * 19 + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Next
End With
End Sub
'1 ,18,35
'1 2 3