How do I hide and password protect a sheet without hardcoding the password?

Cpinhey

New Member
Joined
Jul 7, 2011
Messages
21
How do I hide and password protect a sheet without hardcoding the password?

I've searched the forums and can't find an example where passwords are not hard-coded, hence this new thread.

I have 11 sheets in my workbook, a summary sheet (visible) and 10 input sheets (xlveryhidden and require a password to open using an Input Box). The passwords for the 10 hidden sheets are currently hard-coded, but, I need to let a novice excel user who is an admin user of the workbook determine the the passwords. I have added a sheet called "Login". This sheet contains a list of sheet names and corresponding passwords, I plan to make the "Login" sheet xlveryhidden and add code to a button on the summary sheet that will unhide the "Login" sheet for the admin user. The summary sheet will also contain buttons with code to access each of the 10 input sheets - for example....

Private Sub UnhideSheet()
pword = InputBox("Please Enter a Password", "Unhide Sheet")
If pword <> "password" Then ActiveSheet.Visible = False
End Sub

Does anyone have advice as to how I change this example code so it refers to the cell containing the password on the "Login" sheet?

I'm open to other suggestions on how I can achieve my goal.

Thank you in advance for any assistance you can provide.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This compares to the password in cell A1 of the Login sheet. It doesn't matter if Login sheet is hidden.

If pword <>
Sheets("Login").Range("A1").Value Then ActiveSheet.Visible = False
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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