• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Password Protect single worksheet in a workbook

Injinia

Member
Hi,


I would like to put a password to a single sheet(name: "Sheet 2") on my workbook. I have a hyperlink on "Sheet 1" cell "G1". I would like to be prompted for a password to open sheet 2, every time I click on the hyperlink. Kindly help!


-Injinia
 
I don't think you can do all of this with just a hyperlink, but you could simulate it using some VB and stuff. First, right-click on sheet 2 tab, view code, paste this in:

[pre]
Code:
Private Sub Worksheet_Deactivate()
Me.Visible = 2 'Very hidden
End Sub
Then, in a regular module, put this code

Sub PasswordedSheet()
Dim MyPass As String
Dim UserPass As String

MyPass = "abc123"

UserPass = InputBox("What is the password?", "Password")

If MyPass <> UserPass Then
MsgBox "Please try again"
Exit Sub
End If

With Worksheets("Sheet 2")
.Visible = True
'Which cell on Sheet 2 do you want to go to?
.Range("A1").Select
End With

End Sub
[/pre]
Close the VBE. In your workbook, rather than putting a hyperlink in G1, just create a command button (you could position in cell G1) and assign the macro to it. Will that work?
 
@Injinia

Hi!

Once opened a book nothing prevents from copying a visible worksheet, or adding a new worksheet (if book isn't protected), or adding a new workbook and typing on a clean sheet:

=[ProtectedWorkbook.xlsx]ProtectedWorksheet!A1

And copy this formula all across and down as needed.

This is only a way to display it. With VBA you can get the real formulas, values, ...

Regards!
 
Back
Top