View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Adam Adam is offline
external usenet poster
 
Posts: 287
Default Allowing entry only once

I have the following code which prevents the user to edit the cell A1 more
than once

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Original As Variant
Dim NewVal As Variant
If Target.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
NewVal = Target.Value
Application.EnableEvents = False
Application.Undo
Original = Target.Value
If Original = "" Then
Target = NewVal
Else
MsgBox "No change to this cell is allowed"
End If
Application.EnableEvents = True
End If
End Sub

How do I edit this code to make it work for more than A1 i.e. A1:A100
Thanks
Adam