|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("待出單")
- r = .Cells(.Rows.Count, 1).End(xlUp).row
- arr = .Range("a2:j" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 10)) Then
- Set d(arr(i, 10)) = CreateObject("scripting.dictionary")
- End If
- If Not d(arr(i, 10)).exists(arr(i, 1)) Then
- Set d(arr(i, 10))(arr(i, 1)) = CreateObject("scripting.dictionary")
- End If
- d(arr(i, 10))(arr(i, 1))(i) = ""
- Next
- End With
- With Worksheets("領料單")
- For Each aa In d.keys
- For Each bb In d(aa).keys
- brr = d(aa)(bb).keys
- ReDim crr(1 To 10, 1 To 8)
- .Range("a6:h16").ClearContents
- m = 0
- For k = 0 To UBound(brr)
- m = m + 1
- For j = 1 To 6
- crr(m, j) = arr(brr(k), j)
- Next
- If m = 10 Or k = UBound(brr) Then
- .Range("a6").Resize(UBound(crr), UBound(crr, 2)) = crr
- .print
- .Range("a6:h16").ClearContents
- m = 0
- End If
- Next
- Next
- Next
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|