Sub test()
Application.ScreenUpdating = False
Dim arr, brr(1 To 47), i&, j%, r&, n%, temp
Set d = CreateObject("scripting.dictionary")
With Sheets("报表")
r = .Cells.Find("*", Cells(1, 2), xlValues, xlWhole, xlByRows, xlPrevious).Row
arr = .Range("B3:AV" & r)
For i = 1 To UBound(arr)
If Not d.exists(arr(i, 8)) Then
brr(1) = arr(i, 1)
For j = 3 To UBound(arr, 2)
brr(j - 1) = arr(i, j - 1)
Next j
d(arr(i, 1)) = brr
Else
temp = d(arr(i, 1))
temp(29) = temp(29) + arr(i, 29)
d(arr(i, 1)) = temp
End If
Next i
End With
With Sheets("报表2")
.[a4:AV65536] = ""
.[b4].Resize(d.Count, 47) = arr
End With
Application.ScreenUpdating = True
End Sub
找不到问题。。 |