How do I include my password in a macro?

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
I have a workbook that is used by several end-user with sheets that are password protected so they can't overwrite formulas. I have a button which runs a macro that I recorded that unprotects the sheet, performs several other operations, and then protects the sheet again.

The problem is, that when the macro is run by the end-user, it stops and a drop-down box asks for the password to be entered to unprotect. Obviously, it would be defeating the purpose to give the users the password.

My question is: is there any code I can insert in the macro to automatically enter my password in the box to unprotect, and once again, enter it twice to re-protect?

Thanx in advanx.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Sheets(sheet1).Unprotect Password:="B_2"

Sheets(sheet1).Protect Password:="B_2"
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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