+ Reply to Thread
Results 1 to 7 of 7

count the number of specific data after using autofilter

  1. #1
    Registered User
    Join Date
    01-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2002, 2010
    Posts
    42

    Question count the number of specific data after using autofilter

    Hi all,

    I am using Excel 2002.
    I got a hundred rows of data containing students' weights and heights.
    Here are the sample data before applying autofilter:

    A 175cm 50KG
    B 175cm 51KG
    C 180cm 50KG
    D 175cm 50KG

    I wanted to focus on the students with specific criteria, say students who got 50KG, so I applied the autoFilter, now the visible data after using autoFilter becomes:

    A 175cm 50KG
    C 180cm 50KG
    D 175cm 50KG

    But when I tried to count how many student who are 175cm tall after I have applied autoFilter(), the returned value from countif() was 3, not 2.
    It is trivial that the value should be 2. It seemed that MS Excel has counted in student B who is 175cm 51KG
    I have no idea how to solve this.
    Could you help me please?

    Thank you.
    Last edited by kwfine; 05-19-2011 at 10:03 AM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: count the number of specific data after using autofilter

    The SUBTOTAL function ignores rows hidden by filters.
    =SUBTOTAL(3,A1:A10) counts the non-blank cells in that range.

    Other first argument options.
    Func Num__Function
    1_________AVERAGE
    2_________COUNT
    3_________COUNTA
    4_________MAX
    5_________MIN
    6_________PRODUCT
    7_________STDEV
    8_________STDEVP
    9_________SUM
    10_________VAR
    11_________VARP
    Note: Adding 100 to any of those FuncNums causes the SUBTOTAL function to ignore HIDDEN rows, not just hidden FILTERED rows.
    Example: =SUBTOTAL(103,A1:A20) counts non-blank, non-hidden cells.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: count the number of specific data after using autofilter

    Have a look at the SUBTOTAL function.. it counts/sums, etc filtered lists.

    e.g.

    =SUBTOTAL(3,A1:A100) counts number of items in the filtered list in that range.
    Where there is a will there are many ways.

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

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

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: count the number of specific data after using autofilter

    Your first list shows 3 people 175cm tall. You should correct your example data.

    Use the SUBTOTAL function , the COUNTA option to count the number of visible items in your filtered range:

    =SUBTOTAL(103, A2:A100)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: count the number of specific data after using autofilter

    Does Excel 2002 support 103? I Don't remember when it became available....

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: count the number of specific data after using autofilter

    I don't remember either...Since I've used every version from Excel 4 through Excel 2010, my recollections of the feature additions/deletions get a bit fuzzy sometimes.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: count the number of specific data after using autofilter

    Good catch, NBVC, the 100 series was added in Excel 2003 and all it does it suppress counting of HIDDEN rows, not filtered rows. Filtered rows are always suppressed, even when using the low-level functions.

    Your version of the formula is perfect for that.

+ 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