View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default macro on protected sheet-error

Dave & Paul:
Thanks for the help, but now I have a different problem.

I think one of you helped me with calling specific macros from a combo
box, and it worked fine, UNTIL I protected the sheet.

Now, when calling the macro from the combo box, it will usually pop up
an "Exception Occurred" box. If I run the macros manually or even from
a Forms button, they work fine. It is only trying to run from the
Combo box that gives the error. I tried running it without the sheet
protected and it works just fine.

Is there something I need to check or uncheck in the Protect Sheet box
like I had to do with Sort?
Dave Peterson wrote:
Can you unprotect the worksheet
do the sort
reprotect the worksheet

All in your code?

michaelberrier wrote:

One of many macros in this sheet sorts a range of data based on
specific key cells. The sort will not execute if the worksheet is
protected. It gives the following error:

Runtime Error '1004'
Sort method of range class failed.

Here is the code at the point where it fails:

Range("A7:I999").Select
Selection.Sort Key1:=Range("A8"), Order1:=xlAscending,
Key2:=Range("B8") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom

All the cells in that range are unlocked. I've tried reducing the
range size to only one or two cells to isolate the offender, but the
error persists. Of course, VBE help was none.

Thanks to all.


--

Dave Peterson