|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub tt() 'bysdon7 20141020
- Dim arr, dic, arr1(1 To 100000, 1 To 5), dic2, arr2(1 To 100000, 1 To 2), arr3
- Set dic2 = CreateObject("scripting.dictionary")
- Set dic = CreateObject("scripting.dictionary")
- Dim mxr, mxr3 As Long
- mxr = Sheets("原始").[c65536].End(xlUp).Row
- arr = Sheets("原始").Range("a1:e" & mxr)
- For i = 2 To mxr
- If dic.exists(arr(i, 2) & " " & arr(i, 4)) Then
- hang = dic(arr(i, 2) & " " & arr(i, 4))
- arr1(hang, 5) = Format(arr(i, 5), "h:m:s") '最后一次打卡
- Else
- k = k + 1
- dic(arr(i, 2) & " " & arr(i, 4)) = k
- arr1(k, 1) = arr(i, 2)
- arr1(k, 2) = arr(i, 3)
- arr1(k, 3) = arr(i, 4) '日期
- arr1(k, 4) = Format(arr(i, 5), "h:m:s") '第一次打卡
- End If
- Next i
- For i = 2 To mxr
- If Not dic2.exists(arr(i, 2)) Then
- m = m + 1
- dic2(arr(i, 2)) = m
- arr2(m, 1) = arr(i, 2)
- arr2(m, 2) = arr(i, 3)
- End If
- Next i
- Sheets("整理后").[a3].Resize(m, 2) = arr2
- mxr3 = Sheets("整理后").[a65536].End(xlUp).Row
- arr3 = Sheets("整理后").Range("a1:bj" & mxr3)
- For i = 3 To mxr3
- For j = 3 To 61 Step 2
- If dic.exists(arr3(i, 1) & " " & arr3(1, j)) Then
- hang = dic(arr3(i, 1) & " " & arr3(1, j))
- arr3(i, j) = arr1(hang, 4)
- arr3(i, j + 1) = arr1(hang, 5)
- End If
- Next j
- Sheets("整理后").Range("a1:bj" & mxr3) = arr3
- Next i
- End Sub
复制代码 |
|