|
Sub 考勤统计()
Dim d As Object
Dim ar As Variant
Dim i As Long
Dim br()
Set d = CreateObject("scripting.dictionary")
With Sheets("考勤")
r = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("i2:j" & r) = Empty
ar = .[a1].CurrentRegion
ReDim br(1 To UBound(ar), 1 To 6)
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" And Trim(ar(i, 4)) <> "" Then
rq = CDate(Format(ar(i, 4), "yyyy/mm/dd"))
zf = Trim(ar(i, 2)) & "|" & rq
t = d(zf)
If t = "" Then
k = k + 1
d(zf) = k
t = k
For j = 1 To 3
br(k, j) = ar(i, j)
Next j
br(k, 4) = rq
br(k, 5) = Weekday(rq, 2)
End If
sf = CDate(Format(ar(i, 4), "h:mm:ss"))
fz = Minute(sf)
If fz < 15 Then
js = 0
ElseIf fz >= 15 And fz <= 30 Then
js = 0.5
ElseIf fz > 30 Then
js = 1
End If
If br(t, 5) < 6 Then
br(t, 6) = Hour(sf) - Hour("8:00:00") - 1 + js
Else
br(t, 6) = (Hour(sf) - Hour("8:00:00") - 1 + js) * 2
End If
End If
Next i
End With
With Sheets("统计考勤")
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(k, UBound(br, 2)) = br
End With
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|