Hide Section of Tabs Based On Month

Urzu1000

New Member
Joined
Mar 15, 2016
Messages
5
Hello good people!

I'm creating a single spreadsheet for a daily report. Since there's a report every day, I've created 365 tabs each with a brief short date (01_01, 01_02, 01_03, etc)

It got me thinking... is there a method for hiding tabs based on date using the tab name as a filter? IE, since it's March, could it be made so that only tabs that start with 03_XX show? I'm thinking there isn't, but I've been surprised before in this forum :)

The end user will have hardly any Excel experience, so just hiding and unhiding tabs isn't feasible.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Run this macro

Code:
Sub Show_Month()
    Dim sh As Worksheet, mon As String
    Application.ScreenUpdating = False
    mon = Format(Date, "mm")
    For Each sh In Sheets
        If Left(sh.Name, 2) = mon Then
            sh.Visible = xlSheetVisible
        Else
            sh.Visible = xlSheetHidden
        End If
    Next
    Application.ScreenUpdating = True
    MsgBox "End"
End Sub

INSERT A MODULE
Press Alt-F11 to open the VBA editor. From the menu select Insert > Module. On the sheet that opens, paste the code previous.
Close the editor (press Alt-Q). From Excel, press Alt-F8 to open the macro selector, and select Show_Month and press Run.

To show all sheets, run this:

Code:
Sub show_all()
    For Each sh In Sheets
        sh.Visible = xlSheetVisible
    Next
End Sub
 
Upvote 0
If you have sheet that you want to remain visible at all times you can use
Code:
Sub Urzu1000()
   Dim Ws As Worksheet
   Dim Mnth As String
   
   Mnth = Format(Date + 35, "mm")
   For Each Ws In Worksheets
      If Ws.Name <> "[COLOR=#ff0000]Report[/COLOR]" And Ws.Name <> "[COLOR=#ff0000]Summary[/COLOR]" Then
         Ws.Visible = Left(Ws.Name, 2) = Mnth
      End If
   Next Ws
End Sub
Change the values in red to match sheets that shouldn't get hidden
 
Upvote 0

Forum statistics

Threads
1,214,821
Messages
6,121,755
Members
449,049
Latest member
excelknuckles

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