|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
小白,哪位大神能翻译一下这个代码啊?还有这个代码出来的数据能不能横向排列
Sub kqzl()
ar = Sheet1.[a1].CurrentRegion
ReDim cr(1 To Rows.Count, 1 To 7)
For i = 6 To UBound(ar) Step 2
For j = 1 To UBound(ar, 2)
If ar(i, j) <> "" Then
k = k + 1
cr(k, 1) = k
cr(k, 2) = ar(i - 1, 2)
cr(k, 3) = Left(ar(3, 2), 8) & Format(ar(4, j), "00")
With CreateObject("vbscript.regexp")
.Global = True
.Pattern = "\d{2}:\d{2}"
Set mh = .Execute(ar(i, 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 |
|