|
- Sub test()
- Set d = VBA.CreateObject("scripting.dictionary")
- arr = Sheet1.UsedRange
- For i = 2 To UBound(arr)
- d(arr(i, 3)) = d(arr(i, 3)) & "|" & i
- Next i
- ReDim brr(1 To d.Count, 1 To 12)
- For Each k In d.keys
- r = r + 1
- brr(r, 1) = k
- sp = Split(Mid(d(k), 2), "|")
- brr(r, 2) = UBound(sp) + 1
- brr(r, 3) = arr(sp(0) * 1, 11)
- s1 = 0: s2 = 0
- For x = 0 To UBound(sp)
- s1 = s1 + arr(sp(x) * 1, 7)
- s2 = s2 + arr(sp(x) * 1, 9)
- Next x
- brr(r, 4) = arr(sp(0) * 1, 7)
- brr(r, 5) = arr(sp(0) * 1, 9)
- brr(r, 6) = s1
- brr(r, 7) = s2
- brr(r, 8) = arr(sp(0) * 1, 2)
- brr(r, 9) = arr(sp(0) * 1, 5)
- brr(r, 10) = arr(sp(0) * 1, 4)
- brr(r, 11) = brr(r, 2) * brr(r, 3)
- Next k
- Sheet2.UsedRange.Offset(1) = ""
- Sheet2.Range("b3").Resize(r, 12) = brr
- Set d = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|