+ Reply to Thread
Results 1 to 4 of 4

How do I combine worksheet changes for hiding/unhiding rows?

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    2

    Post How do I combine worksheet changes for hiding/unhiding rows?

    I have a worksheet that has 6 different drop down lists created with data validation. I would like to hide/unhide rows based on drop down selections. I know I can't have more than 1 worksheet change but all are independent of each other so I assume I need to combine together, I’m new to VBA and can’t figure out how to do it. Is this even possible? Is there another way I should be doing it?

    For example, the drop down in D14 has 0 – 5 as the selection options. If 0 is selected then rows 15-80 are hidden, if 1 is selected then rows 15-28 are unhidden, 2 then rows 15-41 are unhidden, 3 then 15-54 are unhidden, 4 then 15-67 are unhidden, and if 5 is selected then none of these rows are hidden.
    The VBA code is :
    Please Login or Register  to view this content.
    This works perfectly but my problem is I need to have other drop downs in the same worksheet act the same way. For example D81 drop down has a selection of 0-6. If 0 is selected then rows 82-88 are hidden, if 1 is selected then rows 82-83 are unhidden, etc.

    Please Login or Register  to view this content.
    Again, this works perfectly but only if the 1st code is not there.

    I have additional hide/unhide instances on the worksheet as well. Some of the drop down lists are numbers and some are yes/no selections.

    Thank you for any help you can give me.
    Last edited by Richard Buttrey; 01-20-2013 at 05:09 PM. Reason: Missing code tags

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do I combine worksheet changes for hiding/unhiding rows?

    Please Login or Register  to view this content.
    Please take a few minutes to read the forum rules, and then edit your post to add CODE tags.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I combine worksheet changes for hiding/unhiding rows?

    Hello and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here. I'll change it for you on this occasion but please note for the future.

    I'm not entirely sure how you're getting the 'Worksheet_Change1(By Val, Target As Range)' line to work since the Change event doesn't have the character 1 embedded in it. I'm assuming you've added this for illustrative purposes.

    There's no reason why you can't use the Sheet Change event to capture various selections.
    Use code like
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-17-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How do I combine worksheet changes for hiding/unhiding rows?

    Thank you Richard for the rule reminder, I will be sure to comply in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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