+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : COUNTIF and COUNTIFS on Visible Cells Only

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Northridge, CA
    MS-Off Ver
    Excel 2007
    Posts
    21

    COUNTIF and COUNTIFS on Visible Cells Only

    OK Folks, I am back once again with an issue I would really appreciate some assistance with. Basically, I have a spreadsheet that a variety of countif and countifs functions that I am using to analyze data with. I need these to count only visible cells after I apply the auto filter. Please see below:

    =COUNTIF(E2:F500, "Y")
    =COUNTIFS(K2:K500, "Y", F2:F500, "Y")

    These are the two examples I need to sove for and the rest of the functions have different cell range references but if I can get a solution on these two, I will be able to trnslate them to the rest f the worksheet. This is what I have tried:

    =SUMPRODUCT(SUBTOTAL(3,OFFSET(E2,ROW(E2:E500)-ROW(E2),0)),(E2:E500="Y")+0)

    It works but I cannot get it to count multiple columns. When I put the range of this formula as E2:F500 in all approprate places I get the #VALUE error. Can someone give me the right formula to use for both of my above scenarios. Your assistance is greatly appreciated.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    Try this for the first

    =SUMPRODUCT((SUBTOTAL(3,OFFSET(E2:F2,ROW(E2:E500)-ROW(E2),0))>0)*(E2:F500="Y"))

    and this version for the second

    =SUMPRODUCT(SUBTOTAL(3,OFFSET(F2,ROW(F2:F500)-ROW(F2),0)),(F2:F500="Y")*(K2:K500="Y"))
    Audere est facere

  3. #3
    Registered User
    Join Date
    01-12-2012
    Location
    Northridge, CA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    Thank you very much! I apologize for posting the additional thread. I utilized your formula and it works however when I filter from any other item other than the first person in the list it does not work and returns blank cells for all the formulas. I have attached a copy of the worksheet with sample data in it. Any helppassback tracker.xlsx would be greatly appreciated.

  4. #4
    Registered User
    Join Date
    02-24-2012
    Location
    ATL, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    Try the Subtotal function - pick count or count A and it will return the number when you filter.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    Quote Originally Posted by aaron1976 View Post
    ......when I filter from any other item other than the first person in the list it does not work and returns blank cells for all the formulas......
    It works OK for me, where are you putting the formulas, obviously they need to be somewhere where they won't be hidden by the filtering, e.g. in row 1

  6. #6
    Registered User
    Join Date
    01-12-2012
    Location
    Northridge, CA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    I have embedded the subtotal in with the sumproduct function. The formula I have is working but when I filter for any one other than the first fileter list choice the cells with the formulas in them return a blank cell.

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Northridge, CA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    AH! That is exactly what is happening, I have the formulas in Row 2 from Columns 0 onward. If I wanted to put these formulas on Sheet 2 or whatever I name that worksheet to in the same workbook, how would I adjust the formula? Sorry for being so needy.

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    If you want to use the formula in another sheet you need to use the sheet name in each of the references, e.g. for that second formula

    =SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!F2,ROW(Sheet1!F2:F500)-ROW(Sheet1!F2),0)),(Sheet1!F2:F500="Y")*(Sheet1!K2:K500="Y"))

  9. #9
    Registered User
    Join Date
    01-12-2012
    Location
    Northridge, CA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: COUNTIF and COUNTIFS on Visible Cells Only

    Thank you very very much. Your formula just confirmed what I entered and evrything is working perfectly.

+ 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