Workbook Protection Password Prompt Macro

banjoflanjo

New Member
Joined
Mar 20, 2008
Messages
44
Hi,

I have a tab that I want to remain hidden to all who do not know the password.

I want the tab to become visible via clicking a button which runs the following code

Sheets("Project Deletion Form").Visible = True

However the workbook is password protected and I would like the user to be prompted for the password once they click the button before the sheet becomes visible.

Can anyone help me with this?

Regards

Banjoflanjo
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Code:
If LCase(Application.InputBox("Enter Password", type:=2)) <> "password" Then Exit Sub
 
Upvote 0
Hi Mike,

Thanks for your reply, my code now looks like this but doesnt work:

Code:
    If LCase(Application.InputBox("Enter Password", Type:=2)) <> "password" Then Exit Sub
    Sheets("Project Deletion Form").Visible = True

Any ideas?

Banjoflanjo
 
Upvote 0
The .Visible property of a worksheet is not a Boolean value, but data type Long.
Code:
Sheets("Project Deletion Form").Visible = xlSheetVisible

Also, "openup" should be substituted for "password" in the code.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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