Public Sub CheckRoad(iRow As Integer)
Dim lLastRow As Long
LastRow& = Cells(Rows.Count, 3).End(xlUp).Row
sRoad = Cells(iRow, 2).Value
Start = Cells(iRow, 3).Value
Finish = Cells(iRow, 4).Value
bWarning = False
For iX = 2 To LastRow
If iX <> iRow Then
If Cells(iX, 2).Value = sRoad Then
If Cells(iX, 3).Value >= Start And Cells(iX, 3).Value <= Finish Then
sName = Cells(iX, 1).Value
bWarning = True
End If
If Cells(iX, 4).Value >= Start And Cells(iX, 4).Value <= Finish Then
sName = Cells(iX, 1).Value
bWarning = True
End If
End If
End If
Next iX
sMessage = "The mile range you entered conflicts with" & sName
sMessage = sMessage & "'s existing territory on I-35. If this "
sMessage = sMessage & "is what you intend to do, please adjust "
sMessage = sMessage & sName & "'s territory on "
sMessage = sMessage & sRoad & " accordingly"
If bWarning Then
Call MsgBox(sMessage, vbInformation)
End If
|