Closed Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    06-07-2007
    Posts
    3

    Subtotals with countif not possible

    sight

    I have 2 columns and hundreds of rows, in the column I have "Yes" or "No".

    I have created an autofilter on column ("country") and I want to know how many "Yes" and "No" answer I get for each column when I apply the filter, since countif ignores hidden rows I thought I can use subtotals but subtotals does not support countif....

    ie:
    Country Yes/No Column
    IN No
    IN No
    IN No
    GB No
    GB No
    GB Yes
    GB Yes
    GB Yes

    when I apply the filter "IN" I only want to count "IN" "yes and "no" values.
    so I get IN = 3 no and 0 yes... not 3 yes and 5 no due to countif ignoring the filter.

    can somebody help?

  2. #2
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,163
    Assuming your table is in A1:B9, then for "No" try:

    Code:
    =SUMPRODUCT(SUBTOTAL(3,OFFSET($B$2:$B$9,ROW($B$2:$B$9)-MIN(ROW($B$2:$B$9)),,1)),--($B$2:$B$9="No"))
    adjust ranges to suit.

    Change "No" to "Yes" in last argument for count of "Yes"
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    11-14-2008
    Location
    Montreal, Quebec, Canada
    MS-Off Ver
    2003
    Posts
    36

    Re: Subtotals with countif not possible

    This works, except for cells with empty values that you are trying to count, too.

    I enclose an example

    in C1 is an example of the solution formula, testing for empty cell. doesn't work.
    in D1 is an example of the solution formula, testing for "N". works.

    My intent is to put both into an IF statement, to alert me if the long list contains a specific value.

    Can anybody assist? that is, make it work for "" and non-"" values?
    Attached Files Attached Files

  4. #4
    Forum Guru martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    10,478

    Re: Subtotals with countif not possible

    you could use some helper columns and convert those to numbers ,say in col c if(or(b2={"y","n"}),1,0)
    then subtotal on those instead
    Mojito connoisseur and a dabbler in Cisco
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

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.2.0