|
发表于 2015-8-16 10:01
|
显示全部楼层
本楼为最佳答案
- Sub lqxs()
- Dim Arr, i&, Sht As Worksheet, Brr, r%, Arr1()
- Dim d, k, t, ks, js, j&, x$
- Set d = CreateObject("Scripting.Dictionary")
- Set Sht = ActiveSheet
- [j4:bz5000].ClearContents
- Brr = Sht.UsedRange
- Arr = Sheets("data").UsedRange
- For i = 4 To UBound(Arr)
- d(Arr(i, 9)) = d(Arr(i, 9)) & Arr(i, 7) & ","
- Next
- For i = 4 To UBound(Brr)
- If Brr(i, 9) = "上班時間" Then
- r = r + 1
- ReDim Preserve Arr1(1 To r)
- Arr1(r) = i
- End If
- Next
- k = Array(0, 1, 7, 8)
- For i = 1 To r
- If i <> r Then
- js = Arr1(i + 1) - 1
- Else
- js = UBound(Brr)
- End If
- ks = Arr1(i): bh = Brr(ks, 1)
- For j = 10 To UBound(Brr, 2)
- x = bh & Format(Brr(3, j), "d/m/yyyy")
- If d.exists(x) Then
- t = d(x)
- t = Left(t, Len(t) - 1)
- If InStr(t, ",") Then
- aa = Split(t, ",")
- Brr(ks, j) = aa(0): Brr(ks + 1, j) = aa(UBound(aa))
- If UBound(aa) > 2 Then
- Brr(ks + 7, j) = aa(1): Brr(ks + 8, j) = aa(2)
- End If
- Else
- Brr(ks, j) = t
- End If
- End If
- Next
- Next
- [a1].Resize(UBound(Brr), UBound(Brr, 2)) = Brr
- End Sub
复制代码 |
|