|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- With Worksheets("装车表")
- bt = .Range("a3:r4")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a6:t" & r)
- For i = 1 To UBound(arr)
- arr(i, 20) = "是"
- Next
- .Range("a6:t" & r) = arr
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 17)) Then
- m = 1
- ReDim brr(1 To m)
- Else
- brr = d(arr(i, 17))
- m = UBound(brr) + 1
- ReDim Preserve brr(1 To m)
- End If
- brr(m) = i
- d(arr(i, 17)) = brr
- Next
- End With
- With Worksheets("发货单")
- .Range("b3") = bt(1, 5)
- .Range("b4") = bt(1, 15)
- .Range("e4") = bt(1, 18)
- .Range("l4") = bt(2, 5)
- .Range("a23:o" & .Rows.Count).Delete shift:=xlUp
- k = 1
- For Each aa In d.keys
- brr = d(aa)
- m = 6
- .Range("e3,l3,b6:n17") = ""
- .Range("e3") = aa
- .Range("l3") = arr(brr(1), 18)
- For i = 1 To UBound(brr)
- For j = 2 To 13
- .Cells(m, j) = arr(brr(i), j)
- Next
- m = m + 1
- If m > 17 Or i = UBound(brr) Then
- k = k + 23
- .Range("a1:o22").Copy .Cells(k, 1)
- m = 6
- .Range("b6:n17") = ""
- End If
- Next
- Next
- .Range("a1:o23").Delete shift:=xlUp
- End With
- Application.ScreenUpdating = True
- MsgBox "发货单生成完毕!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|