|
楼主 |
发表于 2018-9-8 20:26
|
显示全部楼层
Sub 出勤()
Dim Arr, Brr, i%, WT%, wD$, x%, y&
Set Dic = CreateObject("Scripting.Dictionary")
Application.ScreenUpdating = False
Arr = Sheets("出勤时间").[a1].CurrentRegion
ReDim Brr(1 To UBound(Arr), 1 To 100)
For i = 2 To UBound(Arr)
WT = Arr(i, 6) + Arr(i, 7) + Arr(i, 8) + Arr(i, 9)
wD = "第" & WorksheetFunction.WeekNum(Arr(i, 1)) & "周"
If Not Dic.exists(wD) Then
y = y + 1
Dic(wD) = y
Brr(1, y) = wD
End If
If Not Dic.exists(Arr(i, 2)) Then
x = x + 1
Dic(Arr(i, 2)) = x
Brr(x, 1) = Arr(i, 2): Brr(x, 2) = Arr(i, 3)
Brr(x, Dic(wD)) = WT
Else
Brr(Dic(Arr(i, 2)), Dic(wD)) = Brr(Dic(Arr(i, 2)), Dic(wD)) + wD
End If
Next i
Brr(1, 2) = "姓名"
Brr(1, 1) = "工号"
With Sheets("汇算")
Cells.ClearContents
.[a1].Resize(x, y) = Brr
End With
Set Dic = Nothing
Application.ScreenUpdating = True
End Sub现在是这句过不了。
|
|