VBA Code HELP PLEASE!!
Hi Nick,
maybe you are looking for something like this:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
'another If construction
If Not Intersect(Target, Range("e273:g284")) Is Nothing Then
Set rng = Range("e273:g284")
end if
If Not Intersect(Target, Range("g273:j284")) Is Nothing Then
if rng is nothing then
Set rng = Range("g273:j284")
else
set rng = union(rng, Range("g273:j284"))
end if
end if
If Not Intersect(Target, Range("j273:l284")) Is Nothing Then
if rng is nothing then
Set rng = Range("j273:l284")
else
set rng = union(rng, Range("j273:l284"))
End If
end if
'rest of your code
Application.EnableEvents = False
If Not rng Is Nothing Then
If Application.CountIf(rng, Target.Cells(1, 1).Value) 1 Then
MsgBox "This vehicle is booked out at this time"
Target.ClearContents
Target.Cells(1, 1).Select
End If
End If
Application.EnableEvents = True
End Sub
But maybe I misunderstood your question.
Regards,
Ivan
|