|
Sub 工资合计()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
ReDim br(1 To 50000, 1 To 7)
For Each sh In Sheets
If Right(sh.Name, 1) = "月" Then
r = sh.Cells(Rows.Count, 2).End(xlUp).Row
ar = sh.Range("a3:i" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
t = d(Trim(ar(i, 2)))
If t = "" Then
k = k + 1
d(Trim(ar(i, 2))) = k
t = k
br(k, 1) = k
br(k, 2) = ar(i, 2)
End If
For j = 5 To 9
br(t, j - 2) = br(t, j - 2) + ar(i, j)
Next j
End If
Next i
End If
Next sh
With Sheets("工资汇总")
.UsedRange.Offset(2).Borders.LineStyle = 0
.UsedRange.Offset(2) = Empty
.[a3].Resize(k, UBound(br, 2)) = br
.[a3].Resize(k, UBound(br, 2)).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|