+ Reply to Thread
Results 1 to 13 of 13

Macro to hide/show rows based on Drop Down selection

  1. #1
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Macro to hide/show rows based on Drop Down selection

    Hey! So I am trying to work with this file where I want to hide/show rows based on a drop down menu selection in Cell O4 but when I record the macro and run it nothing happens

    So if a person selected "Cash" rows 31-60 would be hidden
    If they selected "Check" rows 14-30 and 47-60 would be hidden
    If they selected "Credit Card" rows 14-46 would be hidden

    Any help would be appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Macro to hide/show rows based on Drop Down selection

    Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make your selection in O4.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

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

    Re: Macro to hide/show rows based on Drop Down selection

    Here you go. Let me know if it is missing anything

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Re: Macro to hide/show rows based on Drop Down selection

    Thank you guys sooo much! A follow up question is there a way to set it up that all the rows are hidden when someone opens the workbook and also they can't proceed to another cell without making a selection in Cell O4?

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Macro to hide/show rows based on Drop Down selection

    Place this macro in the code module for ThisWorkbook. Save the file, close it and re-open it. All the rows from 9 down will be hidden until a selection is made in O4.
    Please Login or Register  to view this content.

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

    Re: Macro to hide/show rows based on Drop Down selection

    You will probably need to incoporate a couple of things to do what you want. Note: The public variable is important. Make sure you keep it.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Re: Macro to hide/show rows based on Drop Down selection

    Mumps1 is there a way to have it where it only hides rows 14 to 60 not all the way up or down when they open the workbook?

    Thanks again for the help!
    Last edited by Bleucherie; 03-03-2015 at 03:57 PM.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Macro to hide/show rows based on Drop Down selection

    Try:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Re: Macro to hide/show rows based on Drop Down selection

    Hiya stnkynts, is there a way to include if a person selects the blank option from the drop down it hides rows 14 to 60 so it essentially won't show them anything until they make a selection? Thanks!
    Last edited by Bleucherie; 03-03-2015 at 04:56 PM.

  10. #10
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Re: Macro to hide/show rows based on Drop Down selection

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    Thanks it worked!

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: Macro to hide/show rows based on Drop Down selection

    Glad to help.

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

    Re: Macro to hide/show rows based on Drop Down selection

    Quote Originally Posted by Bleucherie View Post
    Hiya stnkynts, is there a way to include if a person selects the blank option from the drop down it hides rows 14 to 60 so it essentially won't show them anything until they make a selection? Thanks!
    Yup. Edit this line accordingly

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-20-2015
    Location
    NY
    MS-Off Ver
    Microsoft 365 Version 2501 Build 16.0.18429.20132 64-bit
    Posts
    36

    Re: Macro to hide/show rows based on Drop Down selection

    Quote Originally Posted by stnkynts View Post
    Yup. Edit this line accordingly

    Please Login or Register  to view this content.
    Thank you, thank you, thank you! You guys are awesome

+ 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. Show/Hide rows based on combo box selection and value in two cells
    By merrener in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2013, 05:43 PM
  2. [SOLVED] Hide/show rows with 0 value in column D and E based on case selection
    By say0nara in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-31-2013, 06:34 AM
  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. Hide certain rows based on drop box selection
    By playtowinpb@msn.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2010, 09:09 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