+ Reply to Thread
Results 1 to 10 of 10

Hide rows based on cell content

  1. #1
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Hide rows based on cell content

    Hello all, I know this has been asked a lot of times, and I have tried as many varients as I can find on line with no luck.

    I have a pop up box, with 5 choices. If one of those choices is selected then I need some rows to be hidden, I need this to happen automatically.

    here is the code I have tried (amongst others)


    Please Login or Register  to view this content.
    In practice nothing happens, there is no error or anything, its just nothing happens.

    I do not need to reference the pop up box if it helps, in another cell if never is picked then number 1 is displayed. But I could not work it from this either.

    Many thanks
    Last edited by garyi; 11-13-2010 at 12:18 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,370

    Re: Hide rows based on cell content

    Hi garyi,

    Your code works fine for me. If I have the word "never" in C13 and run the code, rows 14 to 18 are hidden.

    Might you have an extra space in cell C13 like "never " or "Never" or something that doesn't match "never"?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide rows based on cell content

    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
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Hide rows based on cell content

    Hi Marvin, thanks for the feedback. No its perfect so far as I can tell, but that cell is a pop up box could this effect?

    Hi Roy, I tried to do as you ask, but after I clicked the number by my name it just showed the post again?

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,370

    Re: Hide rows based on cell content

    Hi garyi,

    Go to your original message and click the green Edit button. Then below the message click "Go Advanced". Then select the text that is code and above the message area click on the "#" icon. This will put code tags around your code and make us happy.

    Then explain "pop up box".

  6. #6
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Hide rows based on cell content

    Ok, the pop up I mean data validation based on a list which is chosen from selected cells.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,370

    Re: Hide rows based on cell content

    Ok Gary
    I'm closer to understanding "pop up" vs "Drop Down" and you are using a validation cell.

    The answer is that you need someting to trigger your code. I'm assuming the code above is located in a Module and not behind the worksheet.

    You need to create an event that calls the code in your module. You do this with event code that is located behind the worksheet.

    Read http://www.cpearson.com/excel/Events.aspx and then
    http://www.ozgrid.com/VBA/vba-intersect.htm

    Or look at my attached example that creates an event behind the worksheet that calls your code.
    If I was doing it for real I'd test the cell C13 using Target and call the code only if it was what changed.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Hide rows based on cell content

    Thanks Marvin. I have played with your example and it does indeed work. I don't understand how your code works, unless its checking every entry made into excel by the user? i.e. it does not appear to be explicitly checking cell C13?

    Suffice to say I cannot get it to work in my sheet, so I better start reading up.

    Also I am going to need a fair number of these triggers in the sheet depending on what people choose in the drop down box will determine what rows show or do not show.

    I was able to do this in another sheet with true or false statements linked to tick boxes, but they are not appropriate in this situation

  9. #9
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Hide rows based on cell content

    Could I not use a Combo box for this problem? All I would need to do is have a specific cell change value dependant on whats picked in the combo box, and if never is chosen some cells hide. Presumably because its a combo box this would be the 'trigger' for VBA?

  10. #10
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Hide rows based on cell content

    Yes I got it!

    Using a combo box if user picks never it puts 1 in a specified cell which the macros is checking for that number.

    Nice!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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