|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 考勤整理()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long
Dim br()
With Sheets("sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
y = .Cells(1, Columns.Count).End(xlToLeft).Column
If r < 5 Then MsgBox "导入蔬菜定价 工作表为空,请先导入数据!": End
ar = .Range(.Cells(1, 1), .Cells(r, y))
End With
ReDim br(1 To UBound(ar), 1 To 7)
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
n = n + 1
br(n, 1) = ar(i, 1)
br(n, 2) = ar(i, 2)
br(n, 3) = ar(i, 3)
zks = "": zjs = "": xks = "": xjs = ""
For j = 4 To UBound(ar, 2)
If Trim(ar(i, j)) <> "" Then
If TimeValue(ar(i, j)) > TimeValue("8:00:00") And TimeValue(ar(i, j)) < TimeValue("9:00:00") Then
zks = "上午迟到"
End If
If TimeValue(ar(i, j)) > TimeValue("11:00:00") And TimeValue(ar(i, j)) < TimeValue("12:00:00") Then
zjs = "上午早退"
End If
If TimeValue(ar(i, j)) > TimeValue("14:30:00") And TimeValue(ar(i, j)) < TimeValue("16:00:00") Then
xks = "下午迟到"
End If
If TimeValue(ar(i, j)) > TimeValue("16:00:00") And TimeValue(ar(i, j)) < TimeValue("17:30:00") Then
xjs = "下午早退"
End If
End If
Next j
br(n, 4) = zks
br(n, 5) = zjs
br(n, 6) = xks
br(n, 7) = xjs
End If
Next i
With Sheets("考勤统计")
.[a1].CurrentRegion.Offset(1).Borders.LineStyle = 0
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, 7) = br
.[a2].Resize(n, 7).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|