Thread: Locking cells
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
GB GB is offline
external usenet poster
 
Posts: 230
Default Locking cells

Understand, that in using the SelectionChange feature, as you bounce around
the worksheet by selecting different areas, the cell(s) you leave will be
forced to be locked if they are not entered. Might consider just the Change
sub instead. Also if the user inadvertently hits a key and changes locations
or enters the wrong data, you have to deal with that as well...


"michael fuller" wrote:

Copy the following code into each sheet you want the rule to apply to

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Locked < True Then
If ActiveCell < "" Then
ActiveSheet.Unprotect
ActiveCell.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End If
End If

End Sub

If I understand you correctly this should do the trick


"João Costa" wrote in message
...
I mean is there something like an event like the loss of focus by the cell
or
something like that?

Thanks in advance