|
Private Sub CommandButton1_Click()
Dim dic As Object, i%
Set dic = CreateObject("scripting.dictionary")
For i = 3 To Cells(Rows.Count, 1).End(3).Row
If dic.exists(Cells(i, 1).Value) Then
dic(Cells(i, 1).Value) = dic(Cells(i, 1).Value) + Cells(i, 2).Value
Else
dic(Cells(i, 1).Value) = Cells(i, 2).Value
End If
Next i
Range("D:E").Clear
Cells(2, 4).Resize(1, 2) = Array("编号", "金额")
Cells(3, 4).Resize(dic.Count, 1) = Application.Transpose(dic.keys)
Cells(3, 5).Resize(dic.Count, 1) = Application.Transpose(dic.items)
Set dic = Nothing
End Sub
|
评分
-
查看全部评分
|