Cell Protection

M

Moideen

I have been using the below mentioned VBA code for cell protection,
It is protected only one Cell ("A2") We need to protect from A2 to A8
Pls help me.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Address <> "$A$2" Then Exit Sub

Application.EnableEvents = False

MsgBox "Hey, leave me alone!"

Application.Undo

Application.EnableEvents = True

End Su
 
G

GS

Try...

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Range("$A$2:$A$8")) Then
With Application
.EnableEvents = False: .Undo: .EnableEvents = True
End With 'Application
MsgBox "Hey, leave me alone!"
End If
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Top