+ Reply to Thread
Results 1 to 5 of 5

Macro to unhide sheet based on sheet name

  1. #1
    Registered User
    Join Date
    08-10-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Macro to unhide sheet based on sheet name

    Hi,

    I'm trying to look for a simple macro which will unhide sheets based on their sheet name but haven't had any luck. I've got several sheets which I would like to unhide when a command button is clicked. The sheet names are:
    1. Guidance
    2. Template
    3. Schedule of Authority.

    If these are unhidden when the workbook is open because the command button was clicked, I would like these to hide automatically when the workbook is closed so they are not showing when the workbook is opened again.

    Any help would be greatly appreciated. Many thanks.
    Last edited by Samantha McNeill; 08-10-2014 at 09:26 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Macro to unhide sheet based on sheet name

    Create a button on the main sheet of your workbook. Attach this code to it.

    Please Login or Register  to view this content.
    In the Workbook Events, add this to the Before Close Event

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-10-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro to unhide sheet based on sheet name

    Hi Alan,

    Many thanks for your speedy reply. The first part of the code works perfectly. The second part isn't working. Below is what I have added into Workbook events:

    Please Login or Register  to view this content.
    The sheets are not being hidden when I close the workbook. Any ideas why?

    Thanks.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: Macro to unhide sheet based on sheet name

    My bad. Change the Trues to False in the BeforeClose Event. A senior moment in copying code from my workbook to the forum. Please accept my apologies.

  5. #5
    Registered User
    Join Date
    08-10-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Macro to unhide sheet based on sheet name

    All working. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to unhide specific sheet based on worksheet name in cell.
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-29-2013, 08:56 PM
  2. [SOLVED] Hide / Unhide Row on a Sheet based on the Value of a Cell on Another Sheet
    By neslotna in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2013, 12:23 PM
  3. [SOLVED] Macro to Copy Data from one Sheet A to Sheet B based on value in cell on sheet A
    By scass in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2012, 07:21 PM
  4. Replies: 2
    Last Post: 05-23-2006, 02:20 PM
  5. [SOLVED] Hide/unhide sheet macro based on cell calculation
    By Greg Fisher in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2005, 05:19 PM

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