- Sub ddd()
- Dim brr()
- arr = Sheet2.Range("a1:w" & Sheet2.Range("g65536").End(xlUp).Row)
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- For i = 1 To UBound(arr)
- d(arr(i, 7) & "-" & arr(i, 15)) = d(arr(i, 7) & "-" & arr(i, 15)) + arr(i, 19)
- d1(arr(i, 7) & "-" & arr(i, 15)) = d1(arr(i, 7) & "-" & arr(i, 15)) + arr(i, 20)
- d2(arr(i, 7) & "-" & arr(i, 15)) = d2(arr(i, 7) & "-" & arr(i, 15)) + arr(i, 23)
- Next i
- k = d.keys
- t = d.items
- t1 = d1.items
- t2 = d2.items
- ReDim brr(1 To d.Count, 1 To 5)
- For i = 0 To d.Count - 1
- n = n + 1
- brr(n, 1) = Split(k(i), "-")(0)
- brr(n, 2) = Split(k(i), "-")(1)
- brr(n, 3) = t(i)
- brr(n, 4) = t1(i)
- brr(n, 5) = t2(i)
- Next
- m = 2
- For i = 2 To UBound(brr)
- m = m + 1
- Sheet3.Cells(m, 5) = brr(i, 1)
- For j = 7 To 9
- If brr(i, 2) = Sheet3.Cells(2, j) Then
- Sheet3.Cells(m, j) = brr(i, 2)
- End If
- Next j
- Sheet3.Cells(m, 10) = brr(i, 3)
- Sheet3.Cells(m, 11) = brr(i, 4)
- Sheet3.Cells(m, 15) = brr(i, 5)
- Next i
- End Sub
复制代码 |