+ Reply to Thread
Results 1 to 8 of 8

Hide/Unhide Rows based on Zero Value

  1. #1
    Registered User
    Join Date
    11-10-2008
    Location
    AB
    Posts
    16

    Hide/Unhide Rows based on Zero Value

    Hello All,

    I am graphing data compiled using sumproduct. I have the sumproduct =value linked to a dropdown, so if one value is chosen, all other suproduct rows are 0s except the value chosen.

    This allows the chart to show one value, except the zeroed data still shows on the chart legend. It looks like the only way to remove the legend entries is to hide the zeroed rows.

    Would you be able to show me a VBA that would hide/unhide rows based on whether a cell is zero?

    Attached is a dummy sheet as an example. I would like to hide Rows based on values in column B. If the Value in B,n is 0 I would like to hide row n. These rows will change from 0 to other numbers and if the value in B,n is not 0, I would like to unhide that row.

    Alternatively, is there an easier/more elegant way to do what i'm doing???

    Thanks again for the help, you guys are great!

    -chiz
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-04-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Office 2007 (home) Office 365 (work)
    Posts
    134

    Re: Hide/Unhide Rows based on Zero Value

    Hi

    I think the code below may help you in hiding rows with zero value in column B and un-hiding the rows where the value is no longer zero.

    Please Login or Register  to view this content.
    Last edited by excelxx; 02-04-2010 at 04:11 PM.

  3. #3
    Registered User
    Join Date
    11-10-2008
    Location
    AB
    Posts
    16

    Re: Hide/Unhide Rows based on Zero Value

    Thanks excelxx, it works! There is one problem; it seems to skip over hidden rows, so once a row is hidden it is hidden forever. Any idea on how to make it check hidden rows as well? If not I will insert another macro to unhide all rows.


    Thanks!!

  4. #4
    Forum Contributor
    Join Date
    02-04-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Office 2007 (home) Office 365 (work)
    Posts
    134

    Re: Hide/Unhide Rows based on Zero Value

    Hi chiz

    The macro will unhide hidden rows where the value in the cell is not equal to zero. Did you want to unhide all hidden rows regardless of the value in column B.

    excelxx

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Hide/Unhide Rows based on Zero Value

    This will use Auto-Filter to hide/unhide rows based on changes in values in cells B8:B10 per your sample workbook.
    It is much more efficient than looping.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Palmetto; 02-06-2010 at 10:53 AM.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  6. #6
    Registered User
    Join Date
    11-10-2008
    Location
    AB
    Posts
    16

    Re: Hide/Unhide Rows based on Zero Value

    Thanks Guys,

    excelxx, I think what is happening is when the row is hidden, my sumproduct formula won't update.

    Palmetto, thanks for the code, however when I try and use it, it brings up a macros box, asking which macro to use... what am I doing wrong?

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Hide/Unhide Rows based on Zero Value

    Palmetto, thanks for the code, however when I try and use it, it brings up a macros box, asking which macro to use... what am I doing wrong?
    The code I gave is based on your sample workbook and is designed to go into the sheet module and execute when a cell, in the range of B8:B9, changes value. It was not intended to be assigned to a button.

    To get a precise solution from the start, you should always post a sample workbook that EXACTLY duplicates the structure of your real workbook. In order to avoid more questions, please upload per the aforementioned.

  8. #8
    Forum Contributor
    Join Date
    02-04-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Office 2007 (home) Office 365 (work)
    Posts
    134

    Re: Hide/Unhide Rows based on Zero Value

    Hi chiz

    Are you trying to hide the rows with the series of months? If that's the case do you want to hide the rows when all the months add up to zero. Or are you hiding the rows when a single month is zero?

    Thanks
    excelxx

+ 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