Run-Time Error '1004': Method 'Visible of Object' failed

jwelker12

New Member
Joined
May 1, 2015
Messages
6
I am trying to Hide all of my sheets except for one sheet before I close the file and I keep getting an error and I was wondering if there is something that I need to change. The weird thing is that I only get the error when I use the file in my Mac Version of Microsoft Excel and when I use a PC Microsoft Excel it works just fine for some reason.

Here is the formula that is entered in ThisWorkbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

'Step 1: Declare your variables
Dim ws As Worksheet

'Step 2: Unhide the Starting Sheet
Sheets("START").Visible = xlSheetVisible

'Step 3: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets

'Step 4: Check each worksheet name
If ws.Name <> "START" Then

'Step 5: Hide the sheet
ws.Visible = xlVeryHidden
End If

'Step 6: Loop to next worksheet
Next ws

'Step 7: Save the workbook
ActiveWorkbook.Save

End Sub


Private Sub Workbook_Open()

'Step 1: Declare your variables
Dim ws As Worksheet

'Step 2: Start looping through all worksheets
For Each ws In ThisWorkbook.Worksheets

'Step 3: Unhide the Sheet
Sheets("League Set Up").Visible = xlSheetVisible

'Step 4: Loop to next worksheet
Next ws

'Step 5: Hide the Start Sheet
Sheets("START").Visible = xlVeryHidden

End Sub




If anyone is able to help me please let me know if there is something i am missing.

Thank you
Jay
 
I think the solution to this issue may be trying to hide the only tab that was visible, at least one tab must be visible
 
Upvote 0

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