用一个三维数组代替字典,想到啥就写啥
Sub aa()
Dim ar(1 To 99, 1 To 99, 1 To 999)
rw = Range("b1").End(4).Row
br = Range("b2:n" & rw)
ReDim arr(1 To UBound(br), 1 To 4)
For i = 1 To UBound(br)
x = Val(Mid(br(i, 1), 1, 2)): y = Val(Mid(br(i, 1), 3, 2)): z = Val(Mid(br(i, 1), 5, 3))
r = ar(x, y, z)
If r = "" Then
s = s + 1
ar(x, y, z) = s
arr(s, 1) = br(i, 1)
arr(s, 2) = 1
arr(s, 3) = br(i, 5)
arr(s, 4) = br(i, 13)
Else
arr(r, 2) = arr(r, 2) + 1
arr(r, 3) = arr(r, 3) + br(i, 5)
arr(r, 4) = arr(r, 4) + br(i, 13)
End If
Next
[q2].Resize(s, 4) = arr
End Sub |