Error unprotecting worksheet

D

Dan Winterton

I am getting an error message when I try to use VBA code
to unprotect a worksheet. The code is simple:

Sheets("sheetname").Select
ActiveSheet.Unprotect

There is no password assigned. But I get an
error: "Unprotect method of worksheet class failed."

What am I doing wrong? Any ideas? I have no problem
protecting a worksheet with VBA code (ActiveSheet.Protect
DrawingObjects:="True"... etc...)

Any help is greatly appreciated.
Dan
 
A

Alan

All I can suggest that the workbook has become corrupted in some way. Does
it do the same in another workbook? If not you may have to copy all the data
and codes into a new workbook, a pain I know (speaking from experience)
Regards,
Alan.
 
D

Dave Peterson

What version of excel are you using?

How are you invoking the code?

Do you have any "on error resume next" lines that could be masking any errors
(I'm guessing a typo in the worksheet name stops the .select from working
correctly). And the activesheet isn't what you think it is.
 

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