|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
请参考:
Sub Macro1()
Dim arr, brr(), d As Object, i&, j&, m&, temp$
arr = Range("A1").CurrentRegion
Set d = CreateObject("scripting.dictionary")
ReDim brr(1 To UBound(arr), 1 To 4)
For i = 2 To UBound(arr)
temp = arr(i, 1) & arr(i, 2) & arr(i, 3)
If Not d.Exists(temp) Then
m = m + 1
d(temp) = m
For j = 1 To 4
brr(m, j) = arr(i, j)
Next
Else
brr(d(temp), 4) = brr(d(temp), 4) + arr(i, 4)
End If
Next
Range("A1").CurrentRegion.Offset(1, 0).ClearContents
Range("A2").Resize(m, 4) = brr
End Sub |
|