+ Reply to Thread
Results 1 to 7 of 7

Need macro that will show select sheets based off a selection in drop down box.

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    5

    Need macro that will show select sheets based off a selection in drop down box.

    I have a vba code to show and hide sheets based on the name. I now need a code that will show several sheets based on a word selected in drop down menu. Example if I select south, I want it to show all the store numbers under the south division. I have put all the store numbers under south, central, and north divisions as well as the departments under department name in a data sheet and gave them names under name box. I just need it so when a division is selected it shows the stores belonging to that division. Thank You
    Attached Files Attached Files
    Last edited by giggity03; 10-31-2021 at 04:33 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Need help with macro code

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Need macro that will show select sheets based off a selection in drop down box.

    Please Login or Register  to view this content.
    Last edited by protonLeah; 10-31-2021 at 06:50 PM.
    Ben Van Johnson

  4. #4
    Registered User
    Join Date
    07-03-2013
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Need macro that will show select sheets based off a selection in drop down box.

    Thank you for the code. I appreciate it. As it runs it is hanging up on the lines below. Do you have any suggestion why? It says runtime error or another time may give just a 400.

    For Each StoreNum In WSF.Index(Range("division.stores"), 0, Division)
    For Each WS In ActiveWorkbook.Sheets
    If InStr(1, Trim(LCase(WS.Name)), Trim(LCase(StoreNum.Value))) > 0 Then
    WS.Visible = True 'xlSheetVisible

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Need macro that will show select sheets based off a selection in drop down box.

    Oh, sorry. I created two named ranges:
    Departments =Data!$B$1:$B$14
    Division.Stores =Data!$C$2:$E$18

    WSF and StoreNum are declared at the top of the module
    Attached Files Attached Files
    Last edited by protonLeah; 10-31-2021 at 07:49 PM.

  6. #6
    Registered User
    Join Date
    07-03-2013
    Location
    Utah
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Need macro that will show select sheets based off a selection in drop down box.

    That is awesome. It works perfect. I will tweak it for the rest of the changes. I greatly appreciate your help

  7. #7
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Need macro that will show select sheets based off a selection in drop down box.

    You're welcome

+ 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. Replies: 20
    Last Post: 09-22-2015, 05:30 AM
  2. Macro to copy Code / Macro Code / 2 Sheets
    By paxile2k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-23-2014, 12:59 AM
  3. [SOLVED] Code to create Macro Button and Assigning Macro code
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2014, 11:30 AM
  4. Unable to edit macro recording code to be a relative code.
    By holaitsme in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-02-2014, 10:51 AM
  5. [SOLVED] Excel Macro Visual Basic code not looking at all sheets with second section of code.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2014, 08:26 AM
  6. [SOLVED] Code with last column and last row to recognize multiple commands through the macro code
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2014, 04:10 PM
  7. Replies: 0
    Last Post: 05-06-2013, 05:45 AM

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