|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, r&, dte As Date, dte1 As Date, strDay$, isFlag As Boolean
Application.ScreenUpdating = False
br = Worksheets(2).[A1].CurrentRegion.Value
ar = [A1].CurrentRegion.Value
For i = 2 To UBound(ar)
dte = CDate(Format(ar(i, 7), "yyyy-m-d"))
dte1 = CDate(Format(ar(i, 7), "HH:MM:SS"))
If dte1 >= CDate("07:50:00") And dte1 <= CDate("19:49:59") Then strDay = "白班" Else strDay = "夜班"
isFlag = False
For j = 1 To UBound(br)
If dte >= br(j, 1) And dte <= br(j, 2) Then
If CBool(InStr(br(j, 4), ar(i, 6))) And CBool(InStr(br(j, 5), ar(i, 8))) And br(j, 3) = strDay Then
ar(i, 9) = br(j, UBound(br, 2))
isFlag = True
Exit For
End If
End If
Next j
If isFlag = False Then ar(i, 9) = Empty
Next i
[A1].Resize(UBound(ar), UBound(ar, 2)) = ar
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|