|
LangQueS 发表于 2014-4-12 10:32
参考:
你好Dim arr1()
Set d = CreateObject("scripting.dictionary")
arr = Range("a2:c" & Cells(Rows.Count, 2).End(xlUp).Row)
For i = 1 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
n = n + 1
d(arr(i, 1)) = n
ReDim Preserve arr1(1 To 3, 1 To n)
arr1(1, n) = arr(i, 1)
arr1(2, n) = arr(i, 2)
arr1(3, n) = arr(i, 3)
Else
m = d(arr(i, 1))
arr1(2, m) = arr1(2, m) + arr(i, 2)
arr1(3, m) = arr1(3, m) + arr(i, 3)
End If
Next
[e2].Resize(n, 3) = Application.Transpose(arr1)
End Sub
能具体说说程序的说明吗?看了你这个,老是理解不了。
比如说If Not d.exists(arr(i, 1)) Then 明明arr(i, 1)) 是存在的,对吗? |
|