Hide multiple sheets with a macro

pagrender

Well-known Member
Joined
Sep 3, 2008
Messages
652
Hello everyone,

I'd like to alter some VB code to hide all the sheets not labeled "Goals". Basically, what I am trying to do is have a user run a macro, have Excel open the "Goals" tab, and hide all the other sheets in the workbook. Do I need to list all my other sheets, or can VB just hide all sheets and unhide the "Goals" sheet? Here is my current code:


Sub GoToGoals()
'
' GoToGoals Macro
'

'
Sheets("Goals").Select
Range("B6").Select
End Sub


Thanks everybody!

Pete
 
Try:

Code:
Sub Test()
    Dim ws As Worksheet
    Worksheets("Goals").Visible = True
    For Each ws In Worksheets
        ws.Visible = ws.Name = "Goals"
    Next ws
End Sub
 
Upvote 0
hi

is there a way to do a similar process but to hide a group of rows instead with a sheet?

cheers
 
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