|
本帖最后由 hasyh2008 于 2018-8-24 12:29 编辑
Sub 汇总()
Dim dic, X%, arr, dic2
Range("F1").CurrentRegion.Clear
arr = Range("A1").CurrentRegion
Set dic = CreateObject("Scripting.dictionary")
Set dic2 = CreateObject("Scripting.dictionary")
For X = 1 To UBound(arr)
dic(arr(X, 2)) = arr(X, 3)
dic2(arr(X, 2)) = dic2(arr(X, 2)) + arr(X, 4)
Next X
Range("F1").Resize(dic.Count, 1) = WorksheetFunction.Transpose(dic.keys)
Range("G1").Resize(dic.Count, 1) = WorksheetFunction.Transpose(dic.items)
Range("H1").Resize(dic.Count, 1) = WorksheetFunction.Transpose(dic2.items)
End Sub
|
|