|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 去重求和()
Dim 去重 As Object
Dim 求和 As Object
Dim arr, m%
arr = Sheet1.Range("a1").CurrentRegion
Set 去重 = CreateObject("scripting.dictionary")
Set 求和 = CreateObject("scripting.dictionary")
For m = 2 To UBound(arr)
去重(arr(m, 1) & arr(m, 2) & arr(m, 3) & "-" & arr(m, 4)) = arr(m, 5)
Next
For Each d In 去重
名称 = Split(d, "-")(1)
求和(名称) = 求和(名称) + 去重(d)
Next d
求和_key = 求和.keys
求和_item = 求和.items
r = UBound(求和_key)
With WorksheetFunction
Sheet1.Range("h2").Resize(r, 1) = .Transpose(求和_key)
Sheet1.Range("i2").Resize(r, 1) = .Transpose(求和_item)
End With
End Sub
|
|