cell's


Posted by David on December 12, 2000 6:23 PM

Can someone tell me if there is a way to lock a cell without locking the page



Posted by Celia on December 13, 2000 4:24 PM


I think only with VBA. Try the following. It prevents selection of cell A8 :-

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A8")) Is Nothing Then
MsgBox "You may not change cell A8!"
Application.EnableEvents = False
Range("A1").Select
Application.EnableEvents = True
Exit Sub
End If
End Sub

The above, however, does not prevent the contents of another cell being dragged into cell A8, so include also a Worksheet_Change procedure :-

Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Not Intersect(Target, Range("A8")) Is Nothing Then
Application.EnableEvents = False
On Error GoTo e
Application.Undo
Range("A1").Select
Application.EnableEvents = True
Exit Sub
End If
e:
Application.EnableEvents = True
End Sub

Celia