|
Sub 用字典方法统计()
Set D = CreateObject("SCRIPTING.DICTIONARY")
Set d1 = CreateObject("SCRIPTING.DICTIONARY")
ARR = Range("A1").CurrentRegion
ReDim BRR(1 To UBound(ARR), 1 To UBound(ARR)) '
n = 1
For I = 2 To UBound(ARR)
S = ARR(I, 1): f = ARR(I, 3)
If Not D.EXISTS(S) Then
M = M + 1
D(S) = M
End If
If Not d1.EXISTS(f) Then
n = n + 1
d1(f) = n
Cells(1, 5 + n) = f
BRR(M, 1) = ARR(I, 1)
BRR(M, n) = ARR(I, 2)
Else
BRR(D(S), d1(f)) = BRR(D(S), d1(f)) + ARR(I, 2)
End If
Next
[f2].Resize(M, n) = BRR
[f1] = "word"
End Sub |
|