Password protection

N

Noemi

Hi
I have read a number of questions and answers on password protection on
worksheets however I could not find one with the code I am looking to use.

I have a protected worksheet and when a cmd button is selected the worksheet
is unprotected, action in code performed and then worksheet is protected
again however.....

Is it possible when unprotecting the worksheet from VBA that the sheet is
unprotected without a message coming up asking for the password to be
entered, is it possible to enter the password into the code when unprotecting
and when protecting again in VBA that it protects with the password.

Thanks
Noemi
 
G

Gord Dibben

Noemi

Sub SHEETUNPROTECT()
ActiveSheet.Unprotect Password:="justme"

'your code goes here

ActiveSheet.Protect Password:="justme"
End Sub




Hi
I have read a number of questions and answers on password protection on
worksheets however I could not find one with the code I am looking to use.

I have a protected worksheet and when a cmd button is selected the worksheet
is unprotected, action in code performed and then worksheet is protected
again however.....

Is it possible when unprotecting the worksheet from VBA that the sheet is
unprotected without a message coming up asking for the password to be
entered, is it possible to enter the password into the code when unprotecting
and when protecting again in VBA that it protects with the password.

Thanks
Noemi

Gord Dibben MS Excel MVP
 

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