|
学习一下字典
Sub test()
arr = [a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
Set d(arr(i, 1)) = CreateObject("scripting.dictionary")
End If
d(arr(i, 1))(arr(i, 2)) = d(arr(i, 1))(arr(i, 2)) + arr(i, 3)
Next
brr = [e1].CurrentRegion
For i = 2 To UBound(brr)
If d.exists(brr(i, 1)) Then
For j = 2 To UBound(brr, 2)
If d(brr(i, 1)).exists(brr(1, j)) Then
brr(i, j) = d(brr(i, 1))(brr(1, j))
End If
Next
End If
Next
[e1].CurrentRegion = brr
End Sub |
评分
-
1
查看全部评分
-
|