|
- Sub 汇总()
- Dim arr, brr, i%, j%, d, d1
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- arr = Sheet2.Range("A1").CurrentRegion
- For i = 2 To UBound(arr)
- d(arr(i, 1)) = arr(i, 2)
- Next
- Erase arr: j = Sheet1.Range("A1048576").End(xlUp).Row
- arr = Sheet1.Range("A3:N" & j)
- For i = 2 To UBound(arr)
- If d.exists(arr(i, 7)) Then
- arr(i, 14) = d(arr(i, 7))
- d1(d(arr(i, 7))) = ""
- End If
- Next
- d.RemoveAll
- Sheet1.Range("N3").Resize(UBound(arr)) = Application.Index(arr, 0, 14)
- For i = 2 To UBound(arr)
- If arr(i, 14) <> "" Then
- If Not d.exists(arr(i, 4)) Then
- Set d(arr(i, 4)) = CreateObject("scripting.dictionary")
- d(arr(i, 4))(arr(i, 14)) = arr(i, 9)
- Else
- d(arr(i, 4))(arr(i, 14)) = d(arr(i, 4))(arr(i, 14)) + arr(i, 9)
- End If
- End If
- Next
- Rows("2:1048576").Clear
- Range("A2").Resize(d1.Count) = Application.Transpose(d1.keys)
- brr = Range("A1").CurrentRegion
- On Error Resume Next
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- brr(i, j) = d(brr(1, j))(brr(i, 1))
- Next
- Next
- Range("A1").CurrentRegion = brr
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|