|
- Sub qs() '2024/10/19
- Application.ScreenUpdating = False
- Dim arr, i
- arr = Sheet2.Range("a1").CurrentRegion.Value
- brr = Sheet2.Range("a1").CurrentRegion.Value
- st1 = TimeValue("7:00"): st2 = TimeValue("9:30")
- xt1 = TimeValue("14:30"): xt2 = TimeValue("16:30")
- For i = 3 To UBound(arr)
- For j = 3 To UBound(arr, 2)
- If arr(i, j) = "" Then
- brr(i, j) = "未到班"
- Else
- If arr(2, j) = "一" Then
- b = Split(arr(i, j), Chr(10))
- For x = 0 To UBound(b)
- If Len(b(x)) > 0 Then
- If TimeValue(b(x)) > xt2 Then brr(i, j) = "未到班" Else brr(i, j) = "到班"
- End If
- Next
-
- Else
- a = Split(arr(i, j), Chr(10))
- For y = 0 To UBound(a)
- k = 0: tb = ""
- If Len(a(y)) > 0 Then
- If TimeValue(a(y)) >= st1 And TimeValue(a(y)) <= st2 Then
- tb = "上午到班"
- k = k + 1
- Exit For
- End If
- End If
- Next
- If k = 0 Then tb = "未到班"
- For y = 0 To UBound(a)
- k = 0: tb2 = ""
- If Len(a(y)) > 0 Then
- If TimeValue(a(y)) >= xt1 And TimeValue(a(y)) <= xt2 Then
- tb2 = "下午到班"
- k = k + 1
- Exit For
- End If
- End If
- Next
- If k = 0 Then tb2 = "未到班"
- brr(i, j) = tb & Chr(10) & tb2
- End If
- End If
- Next j
- Next
- Sheet2.Range("AF1").Resize(10000, 100) = Empty
- Sheet2.Range("AF1").Resize(10000, 100).Font.ColorIndex = xlAutomatic
- Sheet2.Range("AF1").Resize(UBound(arr), UBound(arr, 2)) = brr
- Dim rng As Range, rn As Range
- Set rng = Sheet2.Range("af1").CurrentRegion
- For Each rn In rng
-
- ta = InStr(rn.Value, "未到班")
- If ta > O Then
- 'MsgBox ta
- rn.Characters(ta, ta + 2).Font.Color = vbRed
- End If
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|