Using Password to show Sheet

Kaieteur

New Member
Joined
Jan 13, 2005
Messages
7
Hi Excel Gurus,
I would like some help again. My workbook automatically loads a macro upon startup but access to a specific sheet (called summary) is only granted to the treasurer by way of a password.

When the treasurer hits the "view Summary" button a userform (containing OK, Cancel buttons, a text box and a label) pops up prompting him to enter his password in the textbox. The reason I went this way is because I want to mask the password. I want when he enters a password and click OK or <Enter> he would be granted access to the sheet, otherwise he would be prompted again to "Enter password). If someone could assist with the code for this I would really appreciate it. I browsed through the Daniel Klann code but that is way too complicated for me.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Kaieteur

New Member
Joined
Jan 13, 2005
Messages
7
This code is OK but it shows the password while the user is typing it in. I have the user typing it into a textbox which masks it, thereby showing *** etc. What I would like to know is how to take this password from the textbox and process it, giving access to the sheet or denying access.

Any help will do.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Here's a pretty generic example for what you're asking.
There are a number of options available to you concerning this subject including using a normal inputbox (no userform) that utilizes the password characters, but this is probably easier to do (and definitely easier to explain :biggrin: ).
Assumes the textbox in use is named TextBox1.
Uses the password "open" (has been made to not be case sensitive).
Unhides a sheet named Sheet1.
Code:
Private Sub CommandButton1_Click()
If UCase(TextBox1) = "OPEN" Then
    Sheets("Sheet1").Visible = True
    Sheets("Sheet1").Select
    Unload Me
Else
MsgBox ("Invalid password"), , "Access Denied"
    TextBox1 = ""
    TextBox1.SetFocus
End If
End Sub
Hope it helps,
Dan
 

Forum statistics

Threads
1,148,216
Messages
5,745,436
Members
423,951
Latest member
peggrif

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
Top