RE: Password protect hidden sheet

Tech-Archive recommends: Speed Up your PC by fixing your registry



Jay,

Would this work for multiple sheets? I have 10 worksheets. Only one person
can access one worksheet, but not the other 9 worksheets.

"Jay" wrote:

Hi Luke -

Here's some draft code to assign to your button's click event. Modify to
suit:

Private Sub CommandButton1_Click()
pwd = "secret"
i_pwd = InputBox("Please Enter Password to Unhide ***", "Unhide ***...")
Select Case i_pwd
Case pwd
Worksheets("Luke'sSheetNameHere").Visible = True
Case Else
MsgBox "Incorrect password; no action taken.", vbInformation,
"Unhide ***..."
End Select
End Sub

Note that users could find the password by entering visual basic and reading
your code. To minimize this possibility, lock the project against viewing
as follows:

In the VB Editor Project Explorer window:

1. Right-click the name of the project and choose 'VBAProject Properties...'.

2. Click the 'Protection' Tab and check the box 'Lock project for viewing'.

3. Enter a password and confirm it. Click [OK] to finish.

4. The VB code will be unviewable the next time you open it (after you save
and close the file).

----
Jay


"Luke" wrote:

I am attempting to create a spreadsheet where one of the sheets is hidden
until clicking a button. The part I can't figure out is I would like it to be
password protected (when you click the button you are prompted for a
password). Does anyone have any recommendations?
My reason for this is only a select number users are supposed to be able to
see this second ***, but no it is not top secret so if somebody were to
somehow bypass it, it would not be the end of the world.
Thanks!
Luke
.


Quantcast