Unprotect cells conditionally in Excel

  Desert Andy 12:41 10 Mar 07
Locked

Hi

I have locked a worksheet, and would like to unhide text and unprotect a cell if the user puts certain text into a different cell. Is this possible?

  VoG II 13:04 10 Mar 07

Something like this. Right click the sheet tab, select View Code. Copy and paste in:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Address(False, False) <> "A1" Then Exit Sub
If UCase(Target.Value) = "UNLOCK" Then
ActiveSheet.Unprotect Password:="pw"
Range("D8").Locked = False
Else
On Error Resume Next
Range("D8").Locked = True
On Error GoTo 0
ActiveSheet.Protect Password:="pw"
End If
End Sub

Close the code window. Typing 'unlock' (without quotes) into A1 should unprotect the sheet and unlock D8. Typing anything else into A1 should lock D8 and protect the sheet.

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

New Corel ParticleShop plugin now available: 11 new brushes & 6 new brush packs

Apple AirPods review: Apple's beautiful new Bluetooth headphones bring true intelligence to…