Macro fails when worksheet protected

G

George Tattam

I have a worksheet with a very simple macro which sorts a range of data on
the last column in the range.The macro runs fine when the worksheet is
unprotected but fails when protected. The error message is "Sort method of
range class failed". I have made sure all the cells in the range are
unlocked.I am running on Windows 2000.Any Ideas?
 
R

Ron de Bruin

Hi George

If you use 2002 or 2003 then when you protect your sheet you check "Sort"
in the list. (Tools>Protection.....Protect sheet)
 
G

George Tattam

Thanks Ron,

I have 2002 at home, but 2000 at work. If I make the changes in 2002, do you
know if they will take in 2000?

George
 
D

Dave Peterson

Nope.

But you could change your macro to unprotect the worksheet, do the sort,
reprotect the worksheet.

worksheets("Sheet1").unprotect password:="hithere"
'do the sort
worksheets("sheet1").protect password:="hithere"
 
G

George Tattam

Great idea.

Thanks Dave.
Dave Peterson said:
Nope.

But you could change your macro to unprotect the worksheet, do the sort,
reprotect the worksheet.

worksheets("Sheet1").unprotect password:="hithere"
'do the sort
worksheets("sheet1").protect password:="hithere"
 

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

Similar Threads


Top