Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Worksheet_Change(ByVal Target As Range)
- Const MyPass As String = "" 'insert sheet protection password
- Application.EnableEvents = False ' prevent the event triggering itself
- If Not Intersect(Target, Me.Range("B2:F8")) Is Nothing Then ' check if target is in editable range
- If Target.Value = "Z119" Then ' test if target value matches the value to trigger cell lock
- Me.Unprotect MyPass ' remove sheet protection
- Target.Locked = True ' lock the target cell as it meets criteria
- Me.Protect MyPass ' reapply sheet protection
- End If
- End If
- Application.EnableEvents = True ' turn on event listening
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement