|
Sub 考勤汇总()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Dim ar As Variant
Dim sh As Worksheet
Dim br()
ReDim br(1 To 1000, 1 To 6)
For Each sh In Sheets
If sh.Name <> "汇总表" Then
y = sh.Cells(3, Columns.Count).End(xlToLeft).Column
x = sh.Cells(Rows.Count, 1).End(xlUp).Row
ar = sh.Range(sh.Cells(1, 1), sh.Cells(x, y))
For i = 6 To UBound(ar)
If Trim(ar(i, 2)) <> "" And Trim(ar(i, 3)) <> "" Then
s = Trim(ar(i, 2)) & "|" & Trim(ar(i, 3))
t = d(s)
If t = "" Then
k = k + 1
d(s) = k
t = k
br(k, 1) = k
br(k, 2) = ar(i, 2)
br(k, 3) = ar(i, 3)
End If
br(t, 4) = br(t, 4) + ar(i, UBound(ar, 2) - 2)
br(t, 5) = br(t, 5) + ar(i, UBound(ar, 2) - 1)
br(t, 6) = br(t, 6) + ar(i, UBound(ar, 2))
End If
Next i
End If
Next sh
With Sheets("汇总表")
.[a1].CurrentRegion.Offset(3) = Empty
.[a4].Resize(k, UBound(br, 2)) = br
End With
MsgBox "ok!"
End Sub
|
|