|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST()
Dim ar, br, i&, r&, dic As Object, vKey
Set dic = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion
For i = 2 To UBound(ar)
vKey = ar(i, 1) & "|" & ar(i, 2)
dic(vKey) = dic(vKey) + ar(i, 3)
Next i
For Each vKey In dic.keys
r = r + 1
br = Split(vKey, "|")
For i = 0 To UBound(br)
ar(r, i + 1) = br(i)
Next i
ar(r, 3) = dic(vKey)
Next
[A11].Resize(r, UBound(ar, 2)) = ar
Set dic = Nothing
Beep
End Sub |
|