|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub AwTest()
Dim i%, x%, r%, y%, c%, s, n%, kStr$, arr, d As Object
Set d = CreateObject("Scripting.Dictionary")
arr = Range("A1:E" & Cells(Rows.Count, 5).End(3).Row)
ReDim brr(1 To UBound(arr), 1 To UBound(arr))
r = 1
brr(r, 1) = "序号": brr(r, 2) = "工单号": brr(r, 3) = "总毛重"
For i = 2 To UBound(arr)
If Len(arr(i, 2)) Then kStr = arr(i, 2)
x = d(kStr)
If x = 0 Then r = r + 1: d(kStr) = r: brr(r, 1) = arr(i, 1): _
brr(r, 2) = arr(i, 2): brr(r, 3) = arr(i, 3): x = r: c = 3
y = d(kStr & "|" & arr(i, 4))
If y = 0 Then c = c + 1: d(kStr & "|" & arr(i, 4)) = c: y = c: s = 0
s = s + arr(i, 5): brr(x, y) = arr(i, 4) & ":" & s
n = Application.Max(n, c)
Next
[f:z].Clear
[g1].Resize(r, n) = brr
End Sub |
评分
-
1
查看全部评分
-
|