|
楼主 |
发表于 2022-2-28 10:43
|
显示全部楼层
- 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 <= 45 Then
- js = 0.5
- ElseIf fz > 45 Then
- js = 1
- [color=DarkOrange] End If
- If br(t, 5) < 6 Then
- br(t, 6) = Hour(sf) - Hour("8:00:00") - 9 + js
- Else
- br(t, 6) = (Hour(sf) - Hour("8:00:00") - 1 + js)[/color]
- 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
复制代码
我想问一下,如果想要将时间改为从18:30开始为加班时间,是不是红色字段修改为 下面这段吗?非常感谢
End If
If br(t, 5) < 6 Then
br(t, 6) = Hour(sf) - Hour("8:00:00") - 10.5 + js
Else
br(t, 6) = (Hour(sf) - Hour("8:00:00") - 10.5 + js) |
|