Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, r&, dte As Date, 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"))
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))) 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
|