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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top