循环一次就可以了
Sub Dicttl1()
Dim d As Object, arr, brr(1 To 99, 1 To 3), i&, M&
Set d = CreateObject("scripting.dictionary")
[D2:F999] = ""
arr = Range("a1").CurrentRegion
For i = 2 To UBound(arr)
If Not d.EXISTS(arr(i, 1)) Then
M = M + 1
brr(M, 1) = arr(i, 1)
brr(M, 2) = 1
brr(M, 3) = arr(i, 2)
d(arr(i, 1)) = M
Else
brr(d(arr(i, 1)), 2) = brr(d(arr(i, 1)), 2) + 1
brr(d(arr(i, 1)), 3) = brr(d(arr(i, 1)), 3) + arr(i, 2)
End If
Next
[d2].Resize(M, 3) = brr
Set d = Nothing
MsgBox "合 计 成 绩 统 计 完 成。"
End Sub |