Right click the sheet tab, view code and paste this in
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = "lock" Then
ActiveSheet.Unprotect
Range("B1").Locked = True
ActiveSheet.Protect
Else
ActiveSheet.Unprotect
Range("B1").Locked = False
ActiveSheet.Protect
End If
End Sub
Assuming you have A1:A10 unlocked and all other cells locked this event code
will unlock adjacent cells in column B.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then Exit Sub
On Error GoTo enditall
Application.EnableEvents = False
If Target.Value <> "" Then
ActiveSheet.Unprotect Password:="justme"
With Target.Offset(0, 1)
.Locked = False
End With
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub
This is sheet event code. Right-click on the sheet tab and "View Code".
Copy/paste into that sheet module.
Gord Dibben MS Excel MVP
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.