+ Reply to Thread
Results 1 to 9 of 9

Hiding multiple rows based on different target values

  1. #1
    Registered User
    Join Date
    09-30-2020
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Hiding multiple rows based on different target values

    Hi all,

    I have a worksheet within which the user selects whether an event is either; On-site (Bridport), Customer (UK) or Customer (International) and based on their choice different rows are hidden. There are 6 different events all with the 3 options and therefore different rows to hide.

    I have the below code that works well for the first event, however, I'm having problems trying to extend it to the multiple events and options. Can anyone help?

    The Target Cells are: B3, B17, B30, B44, B57, B70



    Please Login or Register  to view this content.
    Last edited by help85; 11-09-2021 at 04:10 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,979

    Re: Hiding multiple rows based on different target values

    Try this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-30-2020
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Hiding multiple rows based on different target values

    Sorry, I probably wasn't clearer enough as I tried to keep the length of the post down.

    The target cells all have the same options; On-site (Bridport), Customer (UK) or Customer (International) but I need the macro to hide different rows as below. The code will need to be written so it only hides the rows relevant to that specific question/response (target cell). Hopefully I've not confused you. Thanks for the help!

    B3: On-site (Bridport) - hide rows 6:11, Customer (UK) - hide rows 6:8, Customer (International) - no hidden rows between rows 6:11 , "-" - no hidden rows between rows 2:12
    B17: On-site (Bridport) - hide rows 20:25, Customer (UK) - hide rows 20:22, Customer (International) - no hidden rows between rows 16:26, "-" - no hidden rows between rows 16:26
    B30: On-site (Bridport) - hide rows 33:38, Customer (UK) - hide rows 33:35, Customer (International) - no hidden rows between rows 29-39, "-" - no hidden rows between rows 29-39
    B44:On-site (Bridport) - hide rows 47:52, Customer (UK) - hide rows 47:49, Customer (International) - no hidden rows between rows 43-53, "-" - no hidden rows between rows 43-53
    B57:On-site (Bridport) - hide rows 60:65, Customer (UK) - hide rows 60:62, Customer (International) - no hidden rows between rows 56-66, "-" - no hidden rows between rows 69-79
    B70:On-site (Bridport) - hide rows 73:78, Customer (UK) - hide rows 73:75, Customer (International) - no hidden rows between rows 69-79, "-" - no hidden rows between rows 69-79

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,979

    Re: Hiding multiple rows based on different target values

    Hopefully I've not confused you.
    Well, I guessed as much. But I couldn't second guess what you wanted for each range. So, some work for you to do there.

    The first few lines show you how to eliminate the cells you are not interested in. Then you'll need a separate If block for each cell that gets through.

    As it stands, for each option, you unhide ALL rows and hide the ones you want. You'll need to change that to unhide specific ranges for each cell (of interest) … you can do that at the beginning, before the Select Case block.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,979

    Re: Hiding multiple rows based on different target values

    Untested

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Hiding multiple rows based on different target values

    Sorry Folks Can I refer you back to the original post.


    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,979

    Re: Hiding multiple rows based on different target values

    @mehmetcik: there was a directive asking everyone (senior members) to leave moderating to the Moderators. So, that's what I do these days.

  8. #8
    Registered User
    Join Date
    09-30-2020
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    26

    Re: Hiding multiple rows based on different target values

    Apologies, I've now wrapped my original post.

    @TMS - Thank you for your help, I used your 2nd suggestion and modified as required.

    Many thanks

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,979

    Re: Hiding multiple rows based on different target values

    You're welcome. Thanks for the rep.

    Thanks for adding the code tags.

+ 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] Hiding rows based on Multiple List.
    By Glitch_ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2014, 12:36 PM
  2. [SOLVED] Help with hiding rows based on Column D values
    By Ellen 2Excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2014, 01:58 PM
  3. VBA hiding rows target.value referring to range in another worksheet error
    By siddas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2013, 08:55 AM
  4. Excel 2007 : Hiding rows based on values in cells
    By MiserableLawStdnt in forum Excel General
    Replies: 10
    Last Post: 10-10-2011, 09:22 AM
  5. Help! Hiding rows in sheet2 based on values in sheet1
    By Oti in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-23-2011, 12:47 PM
  6. Hiding rows based on multiple calculations
    By carlito_1985 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2010, 07:28 PM
  7. Hiding Rows under the influence of multiple values.
    By joavery in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-03-2008, 08:30 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