I'm trying to combine an IF Then function with my password protect hidden worksheet codes.
The idea is: when a worksheet is being unhidden, it will request a password, if the Password doesn't work the sheet will be hidden again.
Unfortunately, every time a worksheet that uses this code is accessed the password is requested again. Whether it has already been unhidden or not.
I know what I need to be done can be accomplished with a simple IF Then function, but I can't for the life of me get it to work.
here is an example of the code I am using.
The second Private sub works fine, I thought the top sub would solve the issue I described earlier, but it just makes it so the worksheet never asks for a password.
Thanks in advance for your assistance.
There is no worry about hiding the password for this work book. It's not going to be used by anyone with an understanding of excel.
The idea is: when a worksheet is being unhidden, it will request a password, if the Password doesn't work the sheet will be hidden again.
Unfortunately, every time a worksheet that uses this code is accessed the password is requested again. Whether it has already been unhidden or not.
I know what I need to be done can be accomplished with a simple IF Then function, but I can't for the life of me get it to work.
here is an example of the code I am using.
Code:
Private Sub Worksheet_Show()If Sheet.Visible = False Then
Call Worksheet_unhide
End Sub
Private Sub Worksheet_unhide()
pword = InputBox("Please Enter a Password", "Unhide Sheets")
If pword <> "ILCbogo" Then ActiveSheet.Visible = False
End Sub
The second Private sub works fine, I thought the top sub would solve the issue I described earlier, but it just makes it so the worksheet never asks for a password.
Thanks in advance for your assistance.
There is no worry about hiding the password for this work book. It's not going to be used by anyone with an understanding of excel.