Unprotect

N

Noepie

Hello,

I have a document with three sheets. One of them is hidden (standard
situation). I would like to create a button in one of the other sheets to
automatically change the property of the hidden sheet to visible when I push
the button. But the change to visible should be confirmed by a password which
is preset. If an incorrect password is entered the property of the sheet
remainds hidden. How can I achieve this?

Thanx in advance.

Noepie
 
G

Gord Dibben

Sub unhide_sht1()
pword = InputBox("Enter the password")
If pword = "qwert" Then
Sheets("Sheet1").Visible = True
Else
MsgBox "Incorrect Password"
End If
End Sub

Note: Sheet1 should be set to xlveryhidden or users can unhide simply by
Format>Sheet>Unhide

Lock the code from view by setting ProjectProperties to locked.


Gord Dibben MS Excel MVP
 
M

mikeaj72

Noepie;158755 said:
Hello,

I have a document with three sheets. One of them is hidden (standard
situation). I would like to create a button in one of the other sheets
to
automatically change the property of the hidden sheet to visible when I
push
the button. But the change to visible should be confirmed by a password
which
is preset. If an incorrect password is entered the property of the
sheet
remainds hidden. How can I achieve this?

Thanx in advance.

Noepie
You could also hide the sheet if it is visible in the same macro.
Sub unhide_sht1()
If Sheets("Sheet1").Visible = xlSheetVisible Then
Sheets("Sheet1").Visible = xlSheetVeryHidden
Else
pword = InputBox("Enter the password")
If pword = "qwert" Then
Sheets("Sheet1").Visible = xlSheetVisible
Else
MsgBox "Incorrect Password"
End If
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top