I have a macro the will hide a sheet but will not unhide the sheet. I also get Run-Time error 1004 Application-defined or object-defined error.
When stepping through the code it actually skips past: Sheets("PriceTables").Visible = True
Using excel 365
Sub SheetVisibility()
' Defines variables
Dim pWord As String
' Specifies the desired password response
pWord = "password"
' If the user enters the correct password in the input box then...
If InputBox("Please enter password", "Enter Password") = pWord Then
' If PriceTables Sheet is very hidden then...
If Sheets("PriceTables").Visible = xlVeryHidden Then
' Unhide PriceTables Sheet
Sheets("PriceTables").Visible = True
' Else if PriceTables Sheet is not very hidden then...
Else
' Make PriceTables Sheet very hidden
Sheets("PriceTables").Visible = xlVeryHidden
End If
' Else if the user enters the wrong password in the input box then...
Else
' Display an error stating the password was wrong
MsgBox "That is not the correct password", vbOKOnly, "Incorrect Password"
End If
End Sub
When stepping through the code it actually skips past: Sheets("PriceTables").Visible = True
Using excel 365
Sub SheetVisibility()
' Defines variables
Dim pWord As String
' Specifies the desired password response
pWord = "password"
' If the user enters the correct password in the input box then...
If InputBox("Please enter password", "Enter Password") = pWord Then
' If PriceTables Sheet is very hidden then...
If Sheets("PriceTables").Visible = xlVeryHidden Then
' Unhide PriceTables Sheet
Sheets("PriceTables").Visible = True
' Else if PriceTables Sheet is not very hidden then...
Else
' Make PriceTables Sheet very hidden
Sheets("PriceTables").Visible = xlVeryHidden
End If
' Else if the user enters the wrong password in the input box then...
Else
' Display an error stating the password was wrong
MsgBox "That is not the correct password", vbOKOnly, "Incorrect Password"
End If
End Sub