Error in Macro 2003

L

Lisa

Hi

I have recorded a macro to define certain columns that a user can edit
within a range of a protected worksheet,, but the line keeps giving me an
error at the protection line (marked below with an asterisk) - Runtime error
'1004' Application-defined or object-defined error My Macro looks like this...

' editranges Macro
Sheets("Rep 1").Select
Range("A1").Select
*** ActiveSheet.Protection.alloweditranges.Add Title:="editranges", Range:= _
Range("E:E,G:G,K:K,M:M,O:O,Q:Q,S:S,T:T")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True,
AllowSorting:= _
True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoRestrictions
Range("A1").Select

End Sub

Thanks in advance
 
M

Mike H

Lisa,

You can probably simplify things a bit, try this:-

Sub stance()
Sheets("Rep 1").Select
ActiveSheet.Unprotect
Range("E:E,G:G,K:K,M:M,O:O,Q:Q,S:S,T:T").Select
Selection.Locked = False
ActiveSheet.Protect
Range("E1").Select
End Sub

Mike
 
D

Don Guillett

Or, withOUT selections and from anywhere in the workbook.
Sub stance()
With Sheets("sheet8")
.Unprotect
.Range("E:E,G:G,K:K,M:M,O:O,Q:Q,S:S,T:T").Locked = False
.Protect
End With
End Sub
 

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