G
Grahame Coyle
I'm using the following code within a Worksheet_Change function to
lock/clear and unlock a range of cells. There's also another bit of code in
the function that forces uppercase for cell F3.
If I type "YES" into cell F3 then the cells unlock just fine, but there's a
problem when I try to clear the cell contents. If I select the cell and
press "Delete" the contents ("YES") disappear but the Change event isn't
triggered and the range D10
16 don't lock. However, if I select the cell,
press Backspace then Enter then the Change event triggers and D10:d16 lock
just fine.
So it seems that the Delete key press doesn't constitute an Event. Is that
normal? Can anyone think of a workaround?
Using Excel 2003.
If Target.Address = "$F$3" And UCase(Target.Value) = "YES" Then
ActiveSheet.Unprotect Password:="password"
With Range("$D$10:$D$16")
.Locked = False
End With
ActiveSheet.Protect Password:="jess"
ElseIf Target.Address = "$F$3" And UCase(Target.Value) <> "YES" Then
ActiveSheet.Unprotect Password:="password"
With Range("$D$10:$D$16")
.ClearContents
.Locked = True
End With
ActiveSheet.Protect Password:="jess"
End If
Thanks in advance.
Grahame
lock/clear and unlock a range of cells. There's also another bit of code in
the function that forces uppercase for cell F3.
If I type "YES" into cell F3 then the cells unlock just fine, but there's a
problem when I try to clear the cell contents. If I select the cell and
press "Delete" the contents ("YES") disappear but the Change event isn't
triggered and the range D10
press Backspace then Enter then the Change event triggers and D10:d16 lock
just fine.
So it seems that the Delete key press doesn't constitute an Event. Is that
normal? Can anyone think of a workaround?
Using Excel 2003.
If Target.Address = "$F$3" And UCase(Target.Value) = "YES" Then
ActiveSheet.Unprotect Password:="password"
With Range("$D$10:$D$16")
.Locked = False
End With
ActiveSheet.Protect Password:="jess"
ElseIf Target.Address = "$F$3" And UCase(Target.Value) <> "YES" Then
ActiveSheet.Unprotect Password:="password"
With Range("$D$10:$D$16")
.ClearContents
.Locked = True
End With
ActiveSheet.Protect Password:="jess"
End If
Thanks in advance.
Grahame