Macro to Hide Sheets based on Tab Name

TrimFunction

New Member
Joined
Jan 9, 2018
Messages
18
I have several tabs/worksheets in my workbook with supporting data/lookups/values etc.

I usually unhide all worksheets with a simple macro to update my report, then manually hide them before I send out to an audience.

Is there functionality that will hide worksheets bases on the tab name?

example: if the worksheet/tab names were called "lookup.hid", "oss.hid", "2QData.hid", could a macro hide all sheets with ".hid" in the title?

thanks!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Maybe:
Code:
Sub HideCertainSheets()
Dim Sht As Worksheet
For Each Sht In ActiveWorkbook.Worksheets
    If Sht.Name Like "*.hid" Then Sht.Visible = xlHidden
Next Sht
End Sub
 
Upvote 0
How about
Code:
Sub Hideshts()
   Dim ws As Worksheet
   
   For Each ws In Worksheets
      If Right(ws.Name, 4) = ".hid" Then ws.Visible = xlSheetHidden
   Next ws
End Sub
 
Upvote 0
Thanks @JoeMo, this code worked perfectly!

good quote in your signature, here's another one that I really like:

"When I was a boy of fourteen, my father was so ignorant I could hardly stand to have the old man around. But when I got to be twenty-one, I was astonished at how much he had learned in seven years." - Mark Twain (allegedly)
 
Upvote 0
You are welcome - thanks for the reply.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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