+ Reply to Thread
Results 1 to 8 of 8

VBA Hide/Unhide individual sheets based on selection in drop down menu

  1. #1
    Registered User
    Join Date
    02-05-2015
    Location
    Canada
    MS-Off Ver
    Mac 2011
    Posts
    6

    Question VBA Hide/Unhide individual sheets based on selection in drop down menu

    Hello:

    I have seem many similar questions to mine while googling, however I am yet to come up with a suitable solution for my situation. I have a physical training program template that supports up to 20 athletes. I have a dropdown list with all of the athletes on a sheet, say Sheet1. What I want to be able to do is select the athlete from the drop down list, which well systematically 'unhide' that athletes information sheet. Also, when I select a different athlete's name i would like their sheet to become unhidden and the old athlete's page to become unhidden.

    I have come up with a code that allows the selected athlete to become unhidden, but they do not become 're-hidden', if you will, when i select a different athlete. The code that I'm using to unhide the sheet when it is selected is:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(False, False) = "D1" Then Sheets(Target.Value).Visible = xlSheetVisible
    End Sub

    Also, it would be extremely inefficient to individually code each sheet to open/close when they're particular name is selected from the dropdown list. The athlete lists are lists that will be continually updated and it would not be reasonable to recode the sheet everytime a new athlete is added to the program.

    Thanks in advance for your help!

    Ian.


    EDIT: Cell "D1" is the location of the dropdown list.
    Last edited by igullage; 02-05-2015 at 07:38 PM.

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Try:
    Please Login or Register  to view this content.
    Cheers, berlan

  3. #3
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Hello and welcome to the forum,

    Here's how I would do it :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Try

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-05-2015
    Location
    Canada
    MS-Off Ver
    Mac 2011
    Posts
    6

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    This worked perfectly. Except there was one piece of information i left out. I have 6 other sheets that i need to remain open. (Day1, Day2, Day3... Day6). When i used this code all closed except for the sheet i selected and my "home" sheet. Thanks!

  6. #6
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Apologies, didn't read properly, tired and it is getting late here. stnkynts code works fine; but alternatively only loop the sheet names from the validation list (from the validation formula or linked name range), in case you have other sheets that you would like to hide.

    Regards,
    berlan

  7. #7
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Hi,
    Just edit the code I provide and list the sheets you want to keep here:

    Change :
    Please Login or Register  to view this content.

    to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-05-2015
    Location
    Canada
    MS-Off Ver
    Mac 2011
    Posts
    6

    Re: VBA Hide/Unhide individual sheets based on selection in drop down menu

    Worked perfectly. Exactly what i was looking for. Thanks so much!

    Ian

+ 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. [SOLVED] VBA macro to hide/unhide particular worksheets on selection from drop-down menu
    By lealea1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2014, 09:51 AM
  2. Hide/Unhide Rows Based On Drop Down Selection
    By QABrian in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-14-2014, 11:53 PM
  3. [SOLVED] How to hide & unhide rows based on selection from drop down box?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2013, 08:30 PM
  4. Replies: 1
    Last Post: 02-01-2013, 03:06 PM
  5. Excel 2007 : Hide Sheets using drop-down menu selection
    By SgtGrayMatter in forum Excel General
    Replies: 2
    Last Post: 03-18-2010, 01:29 PM

Tags for this Thread

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