Hide all sheets but a selected one which is not the active sheet

gordonc068

New Member
Joined
Feb 8, 2016
Messages
12
Hi all,

IO have a workbook with many sheets, only some of which the end user interacts with. I have created a Landing Page which has buttons that a pushed to reveal the appropriate sheets based on the action the person wants to take with the workbook. In the case that someone selects the wrong button I would like an easy way for them to rehide all the sheets and return to the Landing Page.

I have seen a lot of posts about making everything be hidden except the active sheet but the landing page will never be the active sheet in this case. Can anyone help me with this? The page Name I would like to remain unhidden on the button click is "Welcome Page - Enable Macros".

Thank you much.
Chris
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try

Code:
Sub HideSheets()
Dim ws As Worksheet
Worksheets("Welcome Page - Enable Macros").Visible = True
For Each ws In Worksheets
    If ws.Name <> "Welcome Page - Enable Macros" Then ws.Visible = False
Next ws
End Sub
 
Upvote 0
You can try this it should work

Sub HideAllSheetsBarOne()
Dim sht As Object

For Each sht In Sheets
If sht.Name <> "Welcome Page" Then
sht.Visible = xlSheetHidden
End If
Next sht

End Sub
 
Upvote 0
Try

Code:
Sub HideSheets()
Dim ws As Worksheet
Worksheets("Welcome Page - Enable Macros").Visible = True
For Each ws In Worksheets
    If ws.Name <> "Welcome Page - Enable Macros" Then ws.Visible = False
Next ws
End Sub


Worked like a charm, thank you very much.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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