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
 

KennyA

Board Regular
Joined
Jul 1, 2015
Messages
84
I changed all the xlSheetVeryHidden to xlSheetHidden and unprotected the Workbook.

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

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,447
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,323
Messages
5,635,586
Members
416,868
Latest member
andiwd

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
Top