+ Reply to Thread
Results 1 to 9 of 9

How to hide a row based on multiple cell values

  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    63

    How to hide a row based on multiple cell values

    I've tried several approaches on how to code this, but can't figure out how to work it. I have a large spreadsheet; which dynamically changes in both column and row counts. So, I have an array of values. If any cell has a negative value, that cell text needs to be changed to red AND that row needs to remain displayed. If ALL values in that row are >=0 then the row can be hidden.

    Not sure if this helps, but the array is actually a pivot table named QTD

    For Example: If cell D5 = 5 and F5 = -3 then Row 5 should remain displayed.
    If Cell D6 = 5 and F6=0 then row 6 should be hidden because all values are > 0

    My approach was to create a dynamically changing named range like so
    Please Login or Register  to view this content.
    Here's a short example of the data

    Person Amnt1 Amnt2 Amnt 3
    1 5 -7 0
    2 10 0 10
    3 15 0 9
    4 20 9 -2

    Rows 2 and 3 should be hidden because all values in those rows are > 0. Rows 1 and 4 shoudl remain visible and Cell B2 and C5 should be red.


    Then I was thinking of using the case statement to hide the rows but can't figure the syntax. I'm open to any other means of performing the taks as long as the initial array dynamically to encompass all the data.


    Thanks,
    Craig
    Last edited by csh8428; 08-06-2012 at 04:44 PM.

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to hide a row based on multiple cell values

    It will be good if you attach a sample file.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    05-16-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: How to hide a row based on multiple cell values

    Quote Originally Posted by arlu1201 View Post
    It will be good if you attach a sample file.
    Arlu,

    I can't upload due to security measures on the flash uploader. I have changed the description of the post that I hope will be sufficient.

    Thanks,

    Craig

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to hide a row based on multiple cell values

    So the unhide/hide operation should be performed on a pivot?

    What is the purpose behind this?

    Even if one cell in the row has a negative amount, the row should be visible?

  5. #5
    Registered User
    Join Date
    05-16-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: How to hide a row based on multiple cell values

    Quote Originally Posted by arlu1201 View Post
    So the unhide/hide operation should be performed on a pivot?

    What is the purpose behind this?

    Even if one cell in the row has a negative amount, the row should be visible?
    Yes, the data is in a pivot. So the operation can be performed on the pivot or outside it as long as the result is the same.
    The purpose is to identify people who have a negative amount in any column. There can be thousands of rows.
    Yes, if one cell in the row has a negative amount the row should be visible. Conversely, if all cells are >= 0 it should be hidden.

    Thanks,

    Craig

  6. #6
    Registered User
    Join Date
    05-16-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: How to hide a row based on multiple cell values

    So I got the dynamic range to work

    Please Login or Register  to view this content.
    Here is what I was thinking along the lines, of but it doesn't work. I'm probably writing it completely wrong. LOL
    Please Login or Register  to view this content.
    Thanks,

    Craig

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to hide a row based on multiple cell values

    I am not sure if the rows can be hidden in a pivot the way you are doing it. Why dont you do the hiding after copying the pivot data onto a sheet without the pivot format?

  8. #8
    Registered User
    Join Date
    05-16-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    63

    Re: How to hide a row based on multiple cell values

    Quote Originally Posted by arlu1201 View Post
    I am not sure if the rows can be hidden in a pivot the way you are doing it. Why dont you do the hiding after copying the pivot data onto a sheet without the pivot format?
    Arlu,

    You can hide rows in the pivot. I have tried it. Even if I copy the data to a new sheet, that still leaves me at square one on how to hide the rows based on my criteria.

    Thanks,

    Craig

  9. #9
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: How to hide a row based on multiple cell values

    Do you have a sample file that you can upload?

+ 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