|
用了个笨办法,凑合用一下吧
- Sub test()
- Application.DisplayAlerts = False
- Dim n%
- n = Cells(Rows.Count, 1).End(xlUp).Row
- Range("E2:E" & n).Copy
- Range("F2").Select
- ActiveSheet.Paste
- Range("F2:F" & n).TextToColumns DataType:=xlDelimited, Space:=True
- Columns("F").Insert
- Columns("F").Insert
- For i = 2 To n
- If Cells(i, 5) <> "" Then
- Cells(i, 6) = Application.WorksheetFunction.Min(Range(Cells(i, 8), Cells(i, Cells(i, 8).End(xlToRight).Column)))
- Cells(i, 7) = Application.WorksheetFunction.Max(Range(Cells(i, 8), Cells(i, Cells(i, 8).End(xlToRight).Column)))
- Range(Cells(i, 8), Cells(i, Cells(i, 8).End(xlToRight).Column)).ClearContents
- Cells(i, 8) = Cells(i, 7) - Cells(i, 6)
- End If
- Next
- Columns("F:H").NumberFormatLocal = "h:mm;@"
- Cells(1, 6) = "最早打卡时间"
- Cells(1, 7) = "最晚打卡时间"
- Cells(1, 8) = "上班时长"
- Columns("F:H").EntireColumn.AutoFit
- Application.DisplayAlerts = True
- End Sub
复制代码 |
|