|
- Sub 考勤统计()
- Dim sht, sht1 As Worksheet, i, n, m, x, y, z As Long, d As Object, arr As Variant
- Set sht = ThisWorkbook.Worksheets(1)
- Set sht1 = ThisWorkbook.Worksheets(2)
- arr = sht.Range("c2:c" & sht.Cells(Rows.Count, 3).End(xlUp).Row)
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To sht.Cells(Rows.Count, 3).End(xlUp).Row - 1
- d(arr(i, 1)) = d(arr(i, 1)) + 1
- Next
- sht1.Cells(3, 1).Resize(d.Count, 1) = WorksheetFunction.Transpose(d.keys)
- sht1.Cells(3, 3).Resize(d.Count, 1) = WorksheetFunction.Transpose(d.items)
- For n = 3 To sht1.Cells(Rows.Count, 3).End(xlUp).Row
- sht1.Cells(n, 3).Value = sht1.Cells(n, 3).Value / 2
- sht1.Cells(n, 1).Value = Replace(sht1.Cells(n, 1).Value, " ", "")
- Next
- For m = 3 To sht1.Cells(Rows.Count, 1).End(xlUp).Row
- y = 0
- z = 0
- For x = 3 To sht.Cells(Rows.Count, 3).End(xlUp).Row
- sht.Cells(x, 3).Value = Replace(sht.Cells(x, 3).Value, " ", "")
- If sht1.Cells(m, 1).Value = sht.Cells(x, 3).Value Then
- Select Case sht.Cells(x, 6)
- Case #8:30:00 AM# To #12:00:00 PM#
- y = y + 1
- sht1.Cells(m, 5).Value = y
- Case #1:00:00 PM# To #5:30:00 PM#
- z = z + 1
- sht1.Cells(m, 6).Value = z
- End Select
- End If
- Next
- Next
- End Sub
复制代码 |
|