I have a worksheet that I want to have different ranges of cells locked, based on a different cells value. What I have right now is something that just locks an individual cell. I can't seem to figure out how to adjust the code to make it work for a range. It is probably very easy, but I cant figure it out. I have a few other ranges that I would want to apply this to, instead of adding the current code I have to each individual cell. But if I could have someone adjust my code for this range, I could adjust it for the others.
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If ActiveCell.Address <> Target.Address Then Exit Sub If Target.Address = "$B$24" Then If [B6] < "2" Then [B24] MsgBox "Invalid amount of" & vbCrLf & _ "outpatient visits", 64, "Access into cell not allowed." End If End If End Sub
The cell that it should be referencing is B6 and the range of cells I want the code to apply to is A24:B27.
Thanks in advance!!
Bookmarks