|
楼主 |
发表于 2023-5-21 19:56
|
显示全部楼层
- Sub ssjss() '2023。4。21
- Dim d, arr, i, r
- Set d = CreateObject("Scripting.dictionary")
- 临时人员 = InputBox("请输入另外计算的人员名单:", , "张凤英")
- r = Sheets("打卡详情").[B65536].End(xlUp).Row
- arr = Sheets("打卡详情").Range("a3:i" & r)
- For i = UBound(arr) To 3 Step -1
- If InStr(临时人员, arr(i, 2)) Then arr(i, 6) = "临时工轮班"
- If (Mid(arr(i, 6), 1, 3) = "仓储部" Or Mid(arr(i, 6), 1, 3) = "临时工") And arr(i, 9) > "18:30" Then
- T = Mid(arr(i, 1), 1, 10) & " " & arr(i, 6)
- If Not d.exists(T) Then
- d(T) = Array("18:00", arr(i, 9), 1, arr(i, 2))
- Else '数组成员:加班开始时间,最早打卡时间,加班人数,加班人员
- If arr(i, 9) < d(T)(1) Then
- rs = d(T)(2) + 1 '加班人数
- ry = d(T)(3) & " " & arr(i, 2) '加班人员
- d(T) = Array("18:00", arr(i, 9), rs, ry)
- Else
- rs = d(T)(2) + 1 '加班人数
- ry = d(T)(3) & " " & arr(i, 2) '加班人员
- d(T) = Array("18:00", d(T)(1), rs, ry)
- End If
- End If
- End If
- Next
- Sheets("VBA算得").[a1].Resize(10000, 8).ClearContents
- Sheets("VBA算得").[a1].Resize(1, 8) = _
- Array("日期", "加班开始", "最早打卡", "上班人数", "姓名", "计算包裹数", "实际包裹数", "加班计时")
- Sheets("VBA算得").[a2].Resize(d.Count, 1) = WorksheetFunction.Transpose(d.keys)
- Sheets("VBA算得").[b2].Resize(d.Count, 4) = Application.Rept(d.items, 1)
- r1 = d.Count + 1
- With Sheets("管家发货记录")
- r = .[B65536].End(3).Row
- For i = 2 To r: T = Mid(.Cells(i, 1).Value, 9, 2): d(T) = .Cells(i, 2): Next
- End With
- With Sheets("VBA算得")
- For i = 2 To r1
- T = Mid(.Cells(i, 1).Value, 9, 2)
- If d.exists(T) Then .Cells(i, "G") = d(T)
- Next
- End With
- Sheets("VBA算得").Range("F2:F" & r1).Formula = "=D2*300"
- Sheets("VBA算得").Range("H2:H" & r1).Formula = "=IF(F2<=G2,FLOOR((C2-B2)*24,0.5),0)"
-
- '以下统计月实际出勤数和加班总时
- r = Sheets("实际出勤").[B65536].End(3).Row
- Sheets("实际出勤").Range("F4:F" & r).Formula = "=COUNTIFS(打卡详情!B:B,B4,打卡详情!J:J,"">1"")"
- Sheets("实际出勤").Range("G4:G" & r).Formula = "=COUNTIFS(打卡详情!B:B,B4,打卡详情!N:N,""*迟*"")"
- Sheets("实际出勤").Range("H4:H" & r).Formula = "=COUNTIFS(打卡详情!B:B,B4,打卡详情!N:N,""*早*"")"
- Sheets("实际出勤").Range("I4:I" & r).Formula = "=COUNTIFS(打卡详情!B:B,B4,打卡详情!N:N,""*假*"")"
- Sheets("实际出勤").Range("K4:K" & r).Formula = "=SUMIF(VBA算得!E:E,""*""&B4&""*"",VBA算得!H:H)" '统计加班
- End Sub
复制代码 |
|