+ Reply to Thread
Results 1 to 11 of 11

Hide/Unhide Sheets based on drop down list

  1. #1
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Question Hide/Unhide Sheets based on drop down list

    Guys,
    I have tried a couple codes from Google for this but without success.
    Is there any one who can help me with this.

    Sheet1--->A1 is drop down list with:
    All
    FIN
    RET
    Oth

    Now, I would like to create VBA code and when I select "All" to unhide ALL SHEETS then.
    If I select FIN, I would like to see "FIN" and to hide RET and Oth.
    Else, if I select RET, Would like to hide FIN and Oth and so on.

    Ideas?

    Thank you in advance.

  2. #2
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: Hide/Unhide Sheets based on drop down list

    Please Login or Register  to view this content.
    This will always leave Sheet 1 and whatever other sheet you select from its dropdown in a1 unhidden, and hide the rest when you run the macro. Add it to a button beside your dropdown?

    EDIT: My bad, forgot about your "All" request.
    Last edited by prjt; 08-31-2016 at 04:27 PM.

  3. #3
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    Is there any way to get something that I don't need to run macro.
    Just on selected "case" from drop down list to hide/unhide specific sheets.
    I would like to avoid "button" for macro.
    Thanks!

  4. #4
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    I've found this solution:
    Please Login or Register  to view this content.
    But now has another problem. In this Sheet I have already had another VBA in this sheet which is "Worksheet_Change".
    Is it possible to fix this?

    And to be more precise in Sheet1 I have drop down menu in A1 and in A2. For A2 drop down menu as I said I have VBA code for hiding rows and now when I put this new code for hiding Sheets, have conflict between 2 "Private Sub Worksheet_Change".
    Last edited by toci; 08-31-2016 at 04:36 PM.

  5. #5
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: Hide/Unhide Sheets based on drop down list

    Please Login or Register  to view this content.


    Dump that into Sheet1's VBA

    EDIT: Remove the target statement all together or change the range from "A1" to "A1:A2", and just add my code to the existing "Worksheet Change" code. ....I believe is the solution
    Last edited by prjt; 08-31-2016 at 04:42 PM.

  6. #6
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    Sure, no problem.

  7. #7
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    I am gonna make an example and put it here because the code above doesn't work for me.

  8. #8
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    Here it is.
    As you can see in VBA I have the code for hiding rows which is connected on cell C4.
    Now I would like to put your code for hiding sheets based on criteria in C5.
    e.g. if I selected in C5 = "All Divisions" then show me all sheets. If it's selected "Financial" hide all except "Region FIN", "Control Tab", "Calculations" and "Actuals".
    Or if I select "Retail" ---> hide all except "Region RET", "Control Tab", "Calculations" and "Actuals"

    I hope so this is an appropriate example for you.
    Thank you very much for help.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: Hide/Unhide Sheets based on drop down list

    Well you had to change some of the specifics like the sheet name and the dropdown cell since you originally specified A1 and Sheet1. I've done it for you below.

    Please Login or Register  to view this content.
    just copy and paste that below your existing code. (Below "Set Changed = Nothing")

    just tested it and worked fine to hide and unhide sheets.
    Last edited by prjt; 08-31-2016 at 06:06 PM.

  10. #10
    Forum Contributor
    Join Date
    11-03-2014
    Location
    Belgrade
    MS-Off Ver
    2010
    Posts
    348

    Re: Hide/Unhide Sheets based on drop down list

    Nope, still doesn't work. Only works fine if I select "All Divisions". When I select "Financial" it hides and "Region FIN" but it should be visible.
    Also if I select case "Financial" and then "Retail" nothing happens.
    I can't figure out on which principle this code works, I mean, how it's know which Sheets to hide?
    What if I add some new sheets?
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    04-03-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010, Excel 2013
    Posts
    75

    Re: Hide/Unhide Sheets based on drop down list

    Quote Originally Posted by toci View Post
    Sheet1--->A1 is drop down list with:
    All
    FIN
    RET
    Oth

    Now, I would like to create VBA code and when I select "All" to unhide ALL SHEETS then.
    If I select FIN, I would like to see "FIN" and to hide RET and Oth.
    Else, if I select RET, Would like to hide FIN and Oth and so on.
    So again... I don't think you really explained yourself very well at all. The code I gave you looks for the value in cell C5 and hides all other sheets WITH THE EXCEPTION of the one with the name matching the value in C5, and the "Control Tab". So either change the names in your dropdown to FIN, RET, etc. OR change the names of your sheets to "Financial", "Retail", etc.

    OTHERWISE, if you must have the two be different I suggest using a Vlookup (in either a column you hide or in a locked cell with white text) on your dropdown and having a list of the dropdown options and their corresponding sheets on a separate sheet/hidden columns. If you do this you will have to modify the code I gave you to point to the Vlookup result and NOT c5 where it currently pulling the value from.

    Again, the code matches the Value of your dropdown and hides all sheets without the matching name, so if you are using values in your drop down that differ from your sheet names it will not work.

+ 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. Hide/unhide sheets based on drop-down menu
    By arindamsenaxa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-16-2016, 10:01 AM
  2. VBA Hide/Unhide individual sheets based on selection in drop down menu
    By igullage in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-05-2015, 08:01 PM
  3. Hide/Unhide cells based on drop-down list
    By Savvy25 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2014, 02:36 AM
  4. Hide-Unhide rows on multiple worksheets based on value of a drop down list
    By clo2peter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-10-2014, 08:32 AM
  5. [SOLVED] hide or unhide rows based on text within a drop down list
    By souimet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 01:32 AM
  6. Unhide or hide sheets based on drop down list value - need help combining these two macros
    By kstrick99999 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-02-2012, 06:07 PM
  7. Hide/unhide columns based on the drop down list value
    By vagif in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2012, 02:13 AM

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