|
发表于 2014-12-19 14:06
|
显示全部楼层
本楼为最佳答案
Sub test()
Dim A, B, d, i&, j%, t$, s&
A = Sheet1.Range("a1").CurrentRegion
ReDim B(1 To UBound(A), 1 To UBound(A, 2))
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(A)
'关键字
t = ""
For j = 1 To UBound(A, 2) - 1
t = t & A(i, j) & ","
Next j
'统计
If d.exists(t) Then
B(d(t), UBound(B, 2)) = B(d(t), UBound(B, 2)) + A(i, UBound(B, 2))
Else
s = s + 1
d(t) = s
For j = 1 To UBound(B, 2)
B(s, j) = A(i, j)
Next j
End If
Next i
Sheet2.Activate
Range("a1").CurrentRegion = ""
Range("a1").Resize(1, UBound(A, 2)) = Application.Index(A, 1, 0)
Range("a2").Resize(UBound(B), UBound(B, 2)) = B
End Sub
求助3 - 副本.rar
(10.56 KB, 下载次数: 164)
|
|