View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default protect sheet when cell is not blank

This goes into the worksheet's code module (right-click on the sheet's name
tab and choose View Code from the list, then copy and paste this into the
module presented to you). Naturally cell N11 is going to have to be unlocked
or you won't be able to clear the entry in it once the sheet goes into
protected state:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$N$11" Then
Exit Sub
End If
If IsEmpty(Target) Then
ActiveSheet.Unprotect Password:="PASS"
Else
ActiveSheet.Protect Password:="PASS"
End If
End Sub


"Wanna Learn" wrote:

Hello
In VBA - Cell N11 is blank, but whenever Cell N11 is not blank I want to
protect the entire sheet with the word "pass"
thanks in advance