unhiding worksheet

KennyA

Board Regular
Joined
Jul 1, 2015
Messages
84
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
 
I changed all the xlSheetVeryHidden to xlSheetHidden and unprotected the Workbook.

IT WORKED!!! Thank you all so very much.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,877
Messages
6,122,051
Members
449,064
Latest member
scottdog129

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top