protected sheet won't execute macro

  • Thread starter Thread starter jefe
  • Start date Start date
J

jefe

I have several macros in a protected sheet. The macros
are for sorting a selection. However, the macros only
work when the protection is not on. When I debug, I get
the following part of the script highlighted.

Selection.Sort Key1:=Range("B3"), Order1:=xlAscending,
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal

I know next to nothing about this VBA stuff so I don't
even know if the highlight means that is where the error
is or if it is stepping through.

I have tried checking and unchecking boxes, when
protecting the sheet, that seem to me that they might have
some bearing on this.

Any ideas would be greatly appreciated.
Thanks
 
It's not a macro problem. You can't sort a protected sheet.

You can, however, with a macro protect the sheet from the user only and make
other macros treat it like it's unprotected. It's done thjis way:
Sheets(1).Protect UserInterfaceOnly:=True

HTH. Best wishes Harald
 
I guess I don't know where to put the macro. I got a
Compile Error:
Invalid Outside Procedure.
I am not sure what that means but it pulled up VBA with
that macro displayed.

I put it in a new module (I think).
 
Simply just re-record the marco...

Unprotect the sheet first... Then Sort it. Then re-protect the sheet.

Then stop the marco

DA
 
Back
Top