|
Sub 汇总()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("总表")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 3 Then MsgBox "总表为空!": End
.Range("i3:j" & r) = Empty
ar = .Range("a1:j" & r)
For i = 3 To UBound(ar)
If ar(i, 3) <> "" Then
d(ar(i, 3)) = i
End If
Next i
For Each sh In Sheets
If InStr(sh.Name, "月") > 0 Then
rs = sh.Cells(Rows.Count, 4).End(xlUp).Row
If rs >= 9 Then
br = sh.Range("b9:f" & rs)
For i = 1 To UBound(br)
If br(i, 3) <> "" Then
xh = d(br(i, 3))
If xh <> "" Then
ar(xh, 9) = ar(xh, 9) + br(i, 4)
ar(xh, 10) = ar(xh, 10) + br(i, 5)
End If
End If
Next i
End If
End If
Next sh
.Range("a1:j" & r) = ar
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|