Sheet Protection doesn't hold

A

Andyjim

I have to unprotect sheets during a macro, move some data, then reprotect.
I'm using an 8 character password. Before running the macro,
Tools>Protection>Unprotect sheet prompts for the password. But after running
the macro (and remember the macro does reprotect with the 8 character
password), it is protected, but Tools>Protection>Unprotect sheet unprotects
it without requiring a password.

I need the formulas and macro code to be inaccessible to users. Is there
some syntax I need to add to make this happen? It seems like the
protect/unprotect in VBA is somehow separate from the protect/unprotect in
the workbook itself. Here's what I'm using:

ActiveSheet.Unprotect Password:="xxxxxxxx"

'data manipulations

ActiveSheet.Protect Password:="xxxxxxxx", DrawingObjects:=True,
Contents:=True, Scenarios:=True
 

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