Sub VBA数组分类汇总()
Dim arr1()
arr = [a2:c13]
For i = 1 To UBound(arr)
ReDim Preserve arr1(1 To 2, 1 To n + 1)
For j = 1 To UBound(arr1, 2)
If arr1(1, j) = arr(i, 1) Then
arr1(2, j) = arr1(2, j) + arr(i, 3)
GoTo 100
End If
Next
n = n + 1
arr1(1, n) = arr(i, 1)
arr1(2, n) = arr(i, 3)
100:
Next
[e2].Resize(n, 2) = Application.Transpose(arr1)
End Sub
|