+ Reply to Thread
Results 1 to 5 of 5

Hide sheet macro based on date

  1. #1
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Hide sheet macro based on date

    I have many sheets in my workbook labelled in the format MMM YYYY

    So Jan 2013, Feb 2013 etc all the way up to Dec 2013 (currently) and as far back as Aug 2012.

    What I want to do is to have a macro that will hide the sheets with dates that are more than 2 months old and more than 2 months in the future of todays date.....
    I do have other sheets in my workbook so those need to remain visible (called "Start", "Template", "Users" and "Graphs")

    If it helps, each sheet that is labelled in the format Mmm YYYY has in it the named range "sh.name" which is the sheet name (funnily enough) in cell A1 of each sheet.

    any ideas?
    Last edited by nickmax1; 03-27-2013 at 09:18 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Hide sheet macro based on date

    You may need to play withe +60 -60 stuff, but something like this:
    Please Login or Register  to view this content.

    or...
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Hide sheet macro based on date

    Wow JBeaucaire your code work very well - how would I reverse the code to unhide all the sheets that were hidden by your macro?

    I think i managed it with this:

    Please Login or Register  to view this content.
    Last edited by nickmax1; 03-27-2013 at 10:36 AM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Hide sheet macro based on date

    My macro does both, it hides an unhides based off of the dates. Yours looks good for an all-purpose unhide all sheets. But if you just want them all showing then this is even easier:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    08-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    721

    Re: Hide sheet macro based on date

    JBeaucaire
    Thanks for your suggestion, but like I said I do have some sheets that are not in the Mmm Yyyy format that i want to remain hidden

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1