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
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