當前位置:成語大全網 - 新華字典 - 簡單的vba問題,求實現的代碼,謝謝!

簡單的vba問題,求實現的代碼,謝謝!

用字典法可以較容易實現

Sub SUMDAT()

Dim i&, r&

Set d = CreateObject("Scripting.Dictionary")

r = Cells(Rows.Count, 1).End(3).Row

arr = Range("a2:b" & r)

For i = 1 To UBound(arr)

d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 2)

Next

y = d.keys

t = d.items

[d2].Resize(UBound(y) + 1, 1) = Application.Transpose(y)

[e2].Resize(UBound(t) + 1, 1) = Application.Transpose(t)

End Sub