+ Reply to Thread
Results 1 to 13 of 13

COUNTIFS Function - HELP

  1. #1
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    COUNTIFS Function - HELP

    Hi Guys,

    I'm trying to use the countif function to display the number of cells with certain text in them.

    for example:

    Column A will have either Car, Bike or Van in the cells and column B will have a date.

    But I want to work out how many Car and Bike are on date 01/01/2015

    This works:
    Please Login or Register  to view this content.
    but is there an easier way for example (I have tried it but doesn't work):
    Please Login or Register  to view this content.
    I don't have to use the countif function if there is a better function/formula to use

    Thanks for any help!

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: COUNTIFS Function - HELP

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIFS Function - HELP

    Quote Originally Posted by InvisibleMan View Post
    =SUM(COUNTIFS(A:A,{"Car","Bike"},B:B,01/01/2015))
    You need to quote the date:

    =SUM(COUNTIFS(A:A,{"Car","Bike"},B:B,"01/01/2015"))
    Last edited by Tony Valko; 02-19-2016 at 08:57 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: COUNTIFS Function - HELP

    Thanks Tony ... just focused on the SUM. Didn't notice the subtle difference in the formulae.

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIFS Function - HELP

    Or, use cells to hold the criteria:

    D1 = car
    D2 = bike
    E1 = 1/1/2015

    =SUMPRODUCT(COUNTIFS(A:A,D1:D2,B:B,E1))

  6. #6
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: COUNTIFS Function - HELP

    Am I right in thinking that SUMPRODUCT isn't good with full column references?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIFS Function - HELP

    Correct.

    However, in this application it's the COUNTIFS function that is evaluating the entire columns and that function does it efficiently.

  8. #8
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: COUNTIFS Function - HELP

    Fair enough. Thought that might be the case but just wanted to check.

  9. #9
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: COUNTIFS Function - HELP

    Thank you very much for your help guys this worked a treat !

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: COUNTIFS Function - HELP

    One more question, if you don't mind pointing me in the right direction.

    If say I had "C1" value = "Feb"

    and a button which opened the xlsx file.

    how would i reference the
    Please Login or Register  to view this content.
    to the Feb.xlsx file, but cell "C1" value wont always equal "Feb" it can equal any other month for example "Jan" or "Mar"

    (the button VBA coding is already sorted its just the COUNTIF formula)

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIFS Function - HELP

    Like this...

    =SUM(COUNTIFS(INDIRECT("'["&C1&".xlsx]Sheet1'!A:A"),{"Car","Bike"},INDIRECT("'["&C1&".xlsx]Sheet1'!B:B"),"01/01/2015"))

    Use the appropriate sheet name.

    Note that the file Feb.xlsx (or whatever the file name) must be open for that formula to work.

  12. #12
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: COUNTIFS Function - HELP

    Thanks Tony

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: COUNTIFS Function - HELP

    You're welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CountIFS Function
    By colegerald38 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-13-2015, 09:31 AM
  2. COUNTIF/COUNTIFS function + nested user-defined function
    By shamjamali in forum Excel General
    Replies: 1
    Last Post: 05-12-2015, 09:12 PM
  3. Use COUNTIFS function on results of DATEVALUE function?
    By Si902 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-16-2015, 08:13 PM
  4. Countifs function in vba
    By Sugisenthil in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-27-2015, 04:56 AM
  5. Help with a countifs function
    By GREYWOLF77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-24-2014, 11:06 AM
  6. Replies: 0
    Last Post: 12-16-2011, 09:01 AM
  7. countifs function
    By doowop5000 in forum Excel General
    Replies: 3
    Last Post: 06-18-2010, 04:13 AM

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