是这个意思吗?满意请给两朵小花,谢谢!
- Sub kqzl()
- r = Application.Max(6, Sheet1.Cells.Find("*", , , , 1, 2).Row)
- ar = Sheet1.Range("a1:ae" & r)
- riqi = Array(, 1, 2, 3, 9, 10, 11, 12, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 28, 29, 30) '指定考勤日期
- ReDim cr(1 To Rows.Count, 1 To 7)
- For i = 6 To UBound(ar) Step 2
- For j = 1 To UBound(riqi)
- k = k + 1
- cr(k, 1) = k
- cr(k, 2) = ar(i - 1, 3)
- cr(k, 3) = Left(ar(3, 3), 8) & Format(ar(4, riqi(j)), "00")
- If ar(i, riqi(j)) <> "" Then
- With CreateObject("vbscript.regexp")
- .Global = True
- .Pattern = "\d{2}:\d{2}"
- Set mh = .Execute(ar(i, riqi(j)))
- For Each mat In mh
- t = TimeValue(mat)
- my_col = IIf(t <= 9.5 / 24, 1, IIf(t <= 12.5 / 24, 2, IIf(t <= 16 / 24, 3, 4))) + 3
- cr(k, my_col) = t
- Next
- End With
- End If
- Next
- Next
- With Sheet3
- .Cells.ClearContents
- .[a1].Resize(1, UBound(cr, 2)) = [{"序号","工号","日期","上午签到","上午签退","下午签到","下午签退"}]
- .[a2].Resize(k, UBound(cr, 2)) = cr
- End With
- End Sub
复制代码
|