Protecting sheet in a macro doesn't work

A

Andyjim

I have a macro that moves data from one sheet to another. It is necessary to
unprotect sheets during the data move, then re-protect them after. I protect
the sheets manually before running the macro, using the same password the
macro uses. But after the macro has run, I find I can unprotect the sheet by
hitting Tools>Protection>Unprotect sheet, and it does not ask for a password;
it goes ahead and unprotects the sheet. Prior to running the macro, it does
ask for the password before unprotecting the sheet. The macro definitely is
reprotecting with the same password. Need to solve this to protect formula
cells in one sheet, and data in the other. I've also tried not protecting
them manually at all, just letting the macro do it. Same result.

This is what I'm using in the macro:
ActiveSheet.Protect Password:="XXXXX"
ActiveSheet.Unprotect Password:="XXXXX"
 

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