Hi,
I have a code that I use to launch an input box, when the correct password is entered it unlocks a specific tab, that was previously VeryHidden. I'd like to modify it so it also hides the current sheet when the answer is correct. When I try to modify, I end up hiding the active sheet whether the password is correct or incorrect. Thank you in advance!
Example, within Sheet1 I click a box, type in a password. If password is correct it unhides Sheet 2 and hides Sheet 1. If it is incorrect, Sheet 1 remains visible and Sheet 2 stays very hidden.
I have a code that I use to launch an input box, when the correct password is entered it unlocks a specific tab, that was previously VeryHidden. I'd like to modify it so it also hides the current sheet when the answer is correct. When I try to modify, I end up hiding the active sheet whether the password is correct or incorrect. Thank you in advance!
Example, within Sheet1 I click a box, type in a password. If password is correct it unhides Sheet 2 and hides Sheet 1. If it is incorrect, Sheet 1 remains visible and Sheet 2 stays very hidden.
Code:
Sub UnlockSheet2()
With Sheets("Sheet2")
.Visible = IIf(InputBox("Enter the correct password") = "PASSWORD", xlSheetVisible, xlSheetVeryHidden)
If .Visible = xlSheetVeryHidden Then MsgBox "Sorry wrong answer, try again!"
End With
End Sub