macros to hide sheet with protection

B

Bakar

hi everyone
I want to have a macros to hide sheet 1
Scenario I am on sheet 2 I click on a command button and I get th
message box for unprotect sheet, I put the password and click ok Sheet
is unhide if I click on cancel I stay on sheet 2 ,when password is o
and when I am on sheet 2 I have another command button when I click on
return on Sheet 1 and sheet 2 is hiding again with the protection.

Thnxs very much for ur precious help
Baka
 
B

Ben McClave

Bakar,

Copy this to a new module, then add a button to sheet1 that links to the "ReHide" macro and a button to sheet2 that links to the "UnHide" macro. You set your password with the very first line of the module, so you may want to password protect the module as well. Here is the code:

Const pWord As String = "Hello123"


Sub UnHide()
If InputBox("Please enter password to open worksheet", "Password?", _
"Enter Password") = pWord Then
Sheet1.Visible = xlSheetVisible
Sheet1.Activate
End If

End Sub

Sub ReHide()
Sheet1.Visible = xlSheetVeryHidden
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