+ Reply to Thread
Results 1 to 13 of 13

Hiding rows based on cell value.

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Hiding rows based on cell value.

    Hello,

    I try to hide row 13 & 14 based on the value of cell D12. The following code doesn't work if I add in VBA (modules: general - worksheet_change).

    Please Login or Register  to view this content.
    Please could you help me? What is my mistake?

    Gijs

  2. #2
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    Hi Metalgijs, welcome to the forum!

    You need to put text values between "" marks.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Hiding rows based on cell value.

    Hi RHCPgergo,

    Thanks for you help, I added your code in the VBA module. Unfortunately the macro doesn't work. If I add no in cell D12 row 13 and 14 doesn’t hide.

    What can be the issue?

    Gijs

  4. #4
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    Another syntax error. You also need quotation marks around the referred row numbers. Sorry, I've tested it now.

    Also note, that it's case sensitive, so typing "No" or "NO" will not hide the rows.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Hiding rows based on cell value.

    Thanks again!

    I really appreciate your help. Still it doesn't work and I presume I am not clear enough with my question. I like to show row 13 and 14 if the answer is yes and hide them in case of no.

    I tried to write this code, but also this code contains mistakes. My knowledge is not enough to see the mistake .

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    Here's the corrected code. (There is no ".Shown" property of the Entirerow object. Also, it's not necessary to select objects to do something with them, I removed that also.)

    Note that if you enter any other value to D12 (other than "yes" or "no"), it won't do anything.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Hiding rows based on cell value.

    Thanks a mil, it works!!!

    I could not find a answer on Google, how do I hide multiple rows based on different cell imputs? The code I wrote is offcourse wrong
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    You're missing an "End if".
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Hiding rows based on cell value.

    I have added a calendar aswell to my worksheet with the following code linked to it (see below). Developer mode, left click on the calendar, view code.

    Is this code blocking the code above? The current code doesn't work in my current workbook. If I check it in a new workbook without a calander it works. How to solve?

    Again many thanks for all the help.

    Please Login or Register  to view this content.

  10. #10
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    I'm not really sure... Both the "Worksheet_SelectionChange" "Worksheet_Change" event macros should be in the worksheet module (not a separate module) to work. If that's not the case, that might cause your problem. Other than that, I'm out of ideas.

  11. #11
    Registered User
    Join Date
    04-09-2013
    Location
    Dublin
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Hiding rows based on cell value.

    I made the suggested change, it works!

    Many thanks!

  12. #12
    Registered User
    Join Date
    04-11-2013
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Hiding rows based on cell value.

    Tried to use the above code repurposed, unsuccessfully. I want to hide rows based on the value of a cell in that row.
    If Cell Y506 is zero, then I want it hidden. If the value in the cell is greater than zero, keep it unhidden.
    I then want to repeat this is an entire range of cells (if cell=0, hide row, if >0, unhide row.)

    Can anyone help?

    Thanks!

  13. #13
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Hiding rows based on cell value.

    Hi basmal8,

    please open a new thread for that.
    Forum Rules

+ 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