+ Reply to Thread
Results 1 to 13 of 13

Subtotal countif?

  1. #1
    Forum Contributor
    Join Date
    06-13-2008
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    277

    Subtotal countif?

    Hi Guys,

    I know there must be a way to do this, I have a filtered list and use the following formulae to count cells which meet a criteria:

    Please Login or Register  to view this content.
    it basically states: ALL CELLS - BLANK CELLS - "N/A" CELLS - "(dd/mm/yy)" CELLS - "(mmm-yy)" CELLS

    I would like this count to reflect the data that has been filtered, at the moment it counts the total regardless of what has been filtered.

    I know you can do this through SUBTOTAL but i have no idea how to get it to recognise text (dates in brackets)

    Any help would be appreciated.

    F
    Last edited by freud1; 10-01-2012 at 06:05 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Sumproduct countif?

    I think you might be thinking of SUBTOTAL rather than SUMPRODUCT.

    SUBTOTAL can exclude filtered and/or hidden rows. Not sure how you'd do that with SUMPRODUCT (Edit: not SUBTOTAL)

    You might be able to produce the count(s) you want with a Helper column. Create a formula that sets a 1 if the row meets all those conditions, and 0 if not.

    Then subtotal the Helper column. The subtotal doesn't have to be in the same column as the Helper "flags" so you could hide the Helper column ... and no one need know.

    Regards, TMS
    Last edited by TMS; 10-01-2012 at 05:31 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-10-2005
    MS-Off Ver
    Excel 2013
    Posts
    95

    Re: Sumproduct countif?

    hi, dont realy get what you mean.. but if you want to count filtered cell example A1: title of header (this is when you filter)

    A2:A10 is the list ..then you can do =subtotal(3,A2:A10), then when you filter A1.. the subtotal will count the cell.

    TMS already explain in previous post..didnt know that

  4. #4
    Forum Contributor
    Join Date
    06-13-2008
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    277

    Re: Sumproduct countif?

    Hi Guys! thank you I meant Subtotal!

    The trouble is I have no idea how to make it work for my countifs.

    Here is an example of my sheet. I need the formula in row 10 to reflect the filtered data and not the total data.
    Attached Files Attached Files

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Subtotal countif?

    Untested..

    =SUMPRODUCT(SUBTOTAL(3,OFFSET(B15:B143,ROW(B15:B143)-ROW(B15),,1)),--(F15:F143<>"("&"*"&"/"&"*"&")"),--(F15:F143<>"("&"*"&"-"&"*"&")"))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  6. #6
    Forum Contributor
    Join Date
    06-13-2008
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    277

    Re: Subtotal countif?

    Thanks Ace!

    Worked a treat!

    Had to add some commas

    many thanks! saved me a bunch of time!

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Subtotal countif?

    Thanks for the rep. Not sure how much I helped; Ace_XL came up with the solution.

    But glad you got an answer to what looked a difficult question.

    Regards, TMS

  8. #8
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Subtotal countif?

    i came up with this monstrosity:

    Please Login or Register  to view this content.
    where list_f = $F$15:$F$143 and list_b = $B$15:$B$143.

    when in unfiltered state, this formula's result is the same as:

    Please Login or Register  to view this content.
    also, your data actually range all the way up to row 332, while the range in your formulae are limited to row 143. i hope you have done this knowingly.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  9. #9
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Subtotal countif?

    ...<>"("&"*"&"/"&"*"&")")...
    i don't think so this will work as wild card character like in COUNTIF. Try this,

    =SUMPRODUCT(SUBTOTAL(3,OFFSET(F15,ROW(F15:F143)-ROW(F15),)),(F15:F143<>"N/A")*(F15:F143<>"")*NOT(ISNUMBER(SEARCH("(*/*)",F15:F143))+ISNUMBER(SEARCH("(*-*)",F15:F143))))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  10. #10
    Forum Contributor
    Join Date
    06-13-2008
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    277

    Re: Subtotal countif?

    thyanks Haseeb,

    Thank ISZ and an applaud for your formula!

    i used this to get the result:

    =SUMPRODUCT(SUBTOTAL(3,OFFSET($B$15:$B$332,ROW($B$15:$B$332)-ROW(B15),,1)),--(F$15:F$332<>"("&"*"&"/"&"*"&")"),--(F$15:F$332<>"("&"*"&"-"&"*"&")"),--(F$15:F$332<>"N/A"))

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

    Re: Subtotal countif?

    Wildcards don't work with comparison operators like <> and =, they are treated as literal asterisks. I suggest you try SEARCH as per Haseeb's suggestion
    Audere est facere

  12. #12
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Subtotal countif?

    thanks, Haseeb and DLL for correcting my error - i wasn't aware of that fact.
    Last edited by icestationzbra; 10-01-2012 at 10:11 PM.

  13. #13
    Forum Contributor
    Join Date
    06-13-2008
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    277

    Re: Subtotal countif?

    Just an update for you guys,

    Haseeb's solution is the best one, as it takes the BRackets into consideration.

    Many thanks!

+ 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