What I am looking to do with this code is I want to look at cells B4:I38 and first see if they have been locked, if so than when a user selects a cell within that range the below message box (in the code) appears. But if the user selects a cell outside of that range than no message appears.
So the first half of this code works, however when the user clicks on a cell outside of the range I get an "Object variable or with block variable not set" run error message. Any help?
So the first half of this code works, however when the user clicks on a cell outside of the range I get an "Object variable or with block variable not set" run error message. Any help?
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("B4:I38").Locked = True And Not Intersect(Target, Range("B4:I38")) Then
MsgBox "Day closed! Requests & adjustments must be emailed to the Workforce Management Team for approval. Thank you!"
Else
'Do nothing
End If
End Sub