Sub a()
Set d = CreateObject("Scripting.Dictionary")
lastrow = Range("A65536").End(xlUp).Row
lastcol = Range("IV1").End(xlToLeft).Column
Range(Cells(2, 3), Cells(lastrow, lastcol)).ClearContents
brr = Range(Cells(1, 2), Cells(lastrow, lastcol))
arr = Worksheets("总表").Range("A2:C" & Worksheets("总表").Range("A65536").End(xlUp).Row)
For i = 1 To UBound(arr)
d(Format(arr(i, 1), "yyyymm") & arr(i, 2)) = d(Format(arr(i, 1), "yyyymm") & arr(i, 2)) + arr(i, 3)
Next i
For i = 2 To UBound(brr)
For j = 2 To UBound(brr, 2)
brr(i, j) = d(Format(brr(1, j), "yyyymm") & brr(i, 1))
Next j
Next i
Range(Cells(1, 2), Cells(lastrow, lastcol)) = brr
End Sub
|