Macro's and password protected sheets

02rj03

New Member
Joined
Jan 15, 2013
Messages
26
Hi there

Is there anyway possible when recording or writing a macro to be able to unlock a password protected sheet then relock and repassword (very important) the same sheet once i have finished with the sheet?

I have tried to make a macro to password protect the sheets. Whilst it protected the sheet it wouldn't put the password in.

Thank you in advance
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
To protect

Code:
ActiveSheet.Protect Password:="abc"
to unprotect

Code:
ActiveSheet.UnProtect Password:="abc"
 
Upvote 0
Recorded macros do not record passwords - it's a security measure. You'll have to edit the macro manually.

You might also like to look up the UserInterfaceOnly parameter of the Protect method..
 
Upvote 0
I would then recommend password protecting the VBA modules, otherwise someone can just go in and look at the code to see the password.
 
Upvote 0
In the Visual Basic Editor, Tools > Project Properties, Protection tab, tick Lock Project for Viewing, enter a password and click OK. Save, close and re-open the workbook to see the effect.
 
Upvote 0
In the Visual Basic Editor, Tools > Project Properties, Protection tab, tick Lock Project for Viewing, enter a password and click OK. Save, close and re-open the workbook to see the effect.

Thankyou very much for your help
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top