Comments on: How to use Excel COUNTIFS and COUNTIF with multiple criteria

The tutorial explains how to use COUNTIFS and COUNTIF formulas with multiple criteria in Excel. You will find a number of examples for different data types – numbers, dates, text, wildcard characters, non-blank cells and more. Continue reading

Comments page 60. Total comments: 2053

  1. Hi.

    I'm trying to count the number of times a specific reason code (27 codes in total) occurs within a specified date range. I was able to use the COUNTIFS statement to identify the date range, but I can't figure out how to add the second part of the equation to the formula - that of now counting how many times each of the 27 codes occurs within the date range. The formula I'm using is:
    =COUNTIFS($A$17:$A$50,">="&$R$30,$A$17:$A$50,"<"&$R$31). Any suggestions as to how I can add the next part of the statement?

    Thanks for your help!
    I

    1. Hello Jane,

      Just add one more Range/Criteria pair to your formula: =COUNTIFS($A$17:$A$50,">="&$R$30,$A$17:$A$50,"<"&$R$31, $B$17:$B$50,$R$32)
      Where $B$17:$B$50 – the cells that contain the reason code, and $R$32 is the cell with the code you want to count.

  2. pls av been trying to formulate a formula for my work and I need ur help. am dealing with different index nos and there various transactions whether credit or debit. I need a formula that can help me count de individual no of credit and debit for each index no and also sum the various credit and debit amount.

    1. Hello Linda,

      I am sorry, it is difficult to suggest something without seeing your data. If you can send a workbook with your sample data at support@ablebits.com, I will try to help.

  3. I found the answer for: COUNTIF(Sursa!$G:$G,"Answered")+COUNTIF(Sursa!$G:$G,"Blind Transfered")+COUNTIF(Sursa!$G:$G,"RONA")

    instead of it, the formula is:
    SUM(COUNTIF(Sursa!$G:$G,{"Answered","Blind Transfered","RONA"}))

    for those who will have this problem in the future.

    1. Great combination Kolegu. Thanks a lot, really helpful

  4. Hi,

    How can I count if criteria is in a list?
    For Example: instead of =COUNTIF(Sursa!$G:$G,"Answered")+COUNTIF(Sursa!$G:$G,"Blind Transfered")+COUNTIF(Sursa!$G:$G,"RONA")

    to have something as countif(Sursa!$G:$G,"Answered" or "Blind Transfered" or "RONA")
    Thank you.

  5. First Column 2nd column
    List =LST what is the formula of getting a shortcut e.g i type
    Cable List next column will automatic appear LST and so and so fort
    Wire Thanks awaiting your prompt response.

  6. OR

    A1 is 6:00 AM
    B1 is 14:00 PM

    A2 is 15:00 PM

    B2 =A2 (This should not appear in the range of A1-B1) it will leave blank

  7. Hi Svetlana,

    this is my problem

    A1 B1 C1
    6:00 - 14:00 14:00 - 20:00 20:00 - 6:00
    A2 = B2 = C2 =
    A3 = B3 = C3 =

    for example, i have a value in different excel sheet.
    if i enter 8:00 am there, it will be automatically appear in A2.
    B2 and C2 will be blank.
    but if i put the value 15:00 pm, it will be automatically appear in B2. A2 and C2 will be blank.

    Hope you can help me with this.. Thanks

  8. How do I use countif to meet the same criteria but across multiple ranges in multiple worksheets?

  9. I am trying to tally the number of calls by day-of-the-week each person has from a table that looks like this but for the entire year:

    JANUARY Sa Su Mo Tu We Th Fr
    James call
    John call call
    Mike call
    Jane call call

    FEBRUARY Sa Su Mo Tu We Th Fr
    James call call
    John call call
    Mike call
    Jane call call

    MARCH Sa Su Mo Tu We Th Fr
    James call
    John call call
    Mike call call
    Jane call

    I have a table at the top of the spreadsheet that shows the results and looks like this:

    Sa call Su call Mo call etc
    James ?? ?? ??
    John ?? ?? ??
    Mike ?? ?? ??
    Jane ?? ?? ??

    What formula do I use that references the names in the left column with the rows to give me the ?? tallies based on day of the week when they occur? Thanks.

  10. Hi,
    Help needed on the formula for getting the desired count as shown in the table.
    Need to get count as 1 when either or both the parts are 100% completed.

    Name Part Status Desired Count
    A LHS 100.0% 1
    A RHS 100.0%

    B LHS 100.0% 1
    B RHS

    C LHS 1
    C RHS 100.0%

    D LHS 0
    D RHS

    Thanks a lot in advance.

  11. Hi

    I have two columns named as Reportable (with Yes or No) and another column named Responsible_Officer.

    I am trying to do a number count for each yes per each individual responsible officer.

  12. Hiya

    I have a workbook with mulitple sheets and an overview sheet.
    The overview has validation list for different months whicg relates to each of the muliple sheets.

    I need a count if where by the sheet name in the range will change depending on the month selected in the validation

    i.e If 'May-14' in cell 'Overview!'C2 - Countif('May-14'!R:R,Criteria)
    If then in overview cell2 it is changed to Jun-14 the Countif will change to Countif('Jun-14'!R:R,Criteria).

    Please help?!

  13. Hi Svetlana,

    I was trying to follow your tutorial and adapt it to my data, but it didn't seem to work. Would you mind helping me troubleshoot please? :)

    I was trying to create a COUNTIF for instances when there's text in column A AND text in column C OR column D.

    Thanks in advance!

    1. Tim,

      See if this works:

      =COUNTIFS(A:A,""&"",C:C,""&"")+=COUNTIFS(A:A,""&"",D:D,""&"")

  14. Hi Svetlana,

    How can I count two different texts in one column?

    So my usual formula is: =COUNTIFS(C:C,"Passed",D:D,"Quebec")
    And its giving my correct figures.

    But if in the column C, i also want to count any other status that says Remediation Passed, how should I say that? No change in column D. I tried something like, COUNTIFS(C:C,"Passed" OR "Remediation Passed",D:D,"Quebec"), but that didn't work.

    Grateful for your insights.

    Cheers

    1. =COUNTIFS(C:C,"Passed",D:D,"Quebec")+COUNTIF(C:C,"Remediation Passed)

      This is useful for differing values.

      or

      =COUNTIFS(C:C,"*Passed",D:D,"Quebec")

      This is more efficient and works to find anything containing the word "Passed" as in your example.

  15. Can I use countifs with more to count more than three ranges and criteria?

    1. Hi Angela,

      Of course, you can. You can actually use up to 127 dirrerent ranges / criteria in one COUNTIFS formula: )

  16. Hi Svetlana,
    Could you be kind enough to help me out on this excel problem I am trying to refer to a particular cell for formatting but there is a conflict. I will appreciate your prompt response.
    I have sent the file to your mail.
    Thanks

    1. Hi!

      In your case, it probably makes sense to look up by 2 columns C and D using an array INDEX / MATCH formula. I've sent you an email with a formula example, hopefully that is the result you are trying to achieve.

  17. Hi, I have a range of cells I want to count for a skills matrix for my staff. The ranges of what I want counted are drop down menus in each of the cells with "Sound", "Advanced", "Expert" etc, and these I wanted counted in the number of times that the cells have one of those words in them. The other cells contain "UnAware" and "Basic" which I dont want counted in the original total, but put in a total for all the types of details entered, this way I will get a % of staff with the desired level of training/competence in the processes they use every day.
    I tried COUNTIFS but I kept getting a zero count even though I used the formula correctly (no error message). Could you please help me work this out?

    1. YES!! This is exactly what I am trying to do, too - and I am getting the same non-error of a zero result. What is the proper way to formulate this?

    2. Hi Brandon,

      I am sorry it's difficult for me to say why this happens without seeing your data. Please send your sample workbook at support@ablebits.com and we'll try to help.

  18. Dear Svetlana,

    Thanks for that. I've sorted it out. Someone had been clearing cells by pressing the space bar and obviously a space is still a character so this was distorting any new entries such as formulas. I've made a note of your resolutions above for future reference. Excellent stuff!

    Your help is much appreciated (and is worth a vodka or two!!).

    Cheers,
    vcoolio.

    1. Thanks Vcoolio, I prefer Baileys : )

  19. Hello Svetlana,

    I noticed that in your tutorial that COUNTIF formulas are used outside the columns/cells that need to be totalled.

    I have a work sheet with a number of columns, one of which is Sales/Purchases. The data in the work sheet is extensive and the columns are very long so I like to keep track of the number of Sales and Purchases for a month by using =COUNTIF(range,"SALE")and the same for Purchases. If I place the formulas in a cell at the top or bottom of this column everything works fine. However, should I place the formulas outside this column all I get is a date (such as January 1900). Am I doing something wrong or is the formula restricted to its specific column?

    Thank you in advance for any help.

    Cheers,
    vcoolio.

    1. I need a help to do below thing. Suppose I have column A which contains values either of A,B or C as Follows.

      Column A
      A
      A
      B
      A
      B
      B
      C
      A
      Now what I have to do is, I want to count pair of AA, AB, AC likewise, based on the two consecutive values, if First row contains A and 2nd row contains A, then AA count should be 1 likewise go on.
      What I tired is I can get count for two cells only using following formula =COUNTIFS(A1, "=A",A2,"=B")
      But I don't how to go on increasing the rows.
      Please help

    2. Hello Vcoolio,

      You can put your formulas in any cells. For the formulas to work correctly, try the following:

      1 Apply the General format to the cell with the formula (press Ctrl + 1 and select General in the Format Cells dialog window).
      2 If you used relative cell references in the range argument, the references got distorted when you copied the formula. Try using the absolute cell references instead (e.g. $B:$B for column B).

      If the above suggestions do not work, please send me a sample workbook at support@ablebits.com and we will try to figure out the source of the problem.

  20. I am trying to add a value for a Alpha value in a cell. The Cell can have an M=5, a C=3 or a Z=1 so in the same cell I want to show a value of the corresponding letter, with a default of "0" if they do not choose either letter.
    Also I am adding another value in a subsequent cell for "C" a value of 1,2,3 will be used as as a negative of 1=-0.5, 2=-1 and 3=-1.5, same values only apply to a Z 4=-.5, 5=-1, and 6=-1.5.

    Thanks for your help in advance...

      1. Dear Svetlana Cheusheva,
        I appreciate your help tremendously!
        can you inform that,
        A
        B
        C
        A
        D
        H
        A
        J
        K
        L
        A
        U

        above there if i use the formula =COUNTIF($F$8:$F$30,"A") than result is 3
        but i wants to know that, How Would I Count Only The Same Name Once/ Count Repeated Items Once.
        Please help me urgently.

        Thanking you,
        Imam Azad
        Macro Cable Ltd
        Dhaka, Bangladesh

        1. Hello Imam,

          If you want to get the list of unique values, you can copy your list to a new sheet and click on the Remove Duplicates icon under the DATA tab.
          If you want to get something different, please describe your task in more details.

          1. ANY UPDATE
            Please be Reply

            IMAM

          2. Dear Svetlana Cheusheva,
            Please help any update.

            Thanking you
            Imam
            Dhaka

          3. Dear Svetlana Cheusheva,

            Please solve my example: Mr. Karim is market visited statement as below-

            Date Code Name Type of Customers

            10 October 2014 100 ABC Traders Traders
            11 October 2014 101 MNZ Traders Traders
            12 October 2014 201 AKA Builders Developers
            13 October 2014 300 PWD Consultant
            14 October 2014 100 ABC Traders Traders
            15 October 2014 300 PWD Consultant
            16 October 2014 201 AKA Builders Developers
            16 October 2014 103 ABD Traders Traders
            17 October 2014 100 ABC Traders Traders
            17 October 2014 101 MNZ Traders Traders
            19 October 2014 104 PQS Traders Traders
            20 October 2014 100 ABC Traders Traders

            Now I want to report/result:

            1. How many times visited there? Ans: 12 times. it's i can do.

            2. How many customers are in visited there?

            Please forward formula how to solve.

            Thanking you,
            Imam Azad
            Macro Cable Ltd
            Dhaka, Bangladesh

  21. Sex Age
    F 14
    F 19
    F 15
    F 14
    F 16
    F 21
    F 24

    how can i count with these limitations? what formula/syntax will i use?
    i need to count all F with age less than 15, F equal to 15 but not more than 19 and all the F equal 20 but not more than 24

    I want to tabulate it in this format.

    F less than 15
    F equal 15 pero not more than 19
    F equal 20 but not more than 24
    thanks for helping me on this one

    1. Hi Gio,

      Try these formulas:

      F is less than 15:
      =COUNTIFS($A$2:$A$8,"F",$B$2:$B$8,"<15")

      F equal 15 pero not more than 19:
      =COUNTIFS($A$2:$A$8,"F",$B$2:$B$8,">=15",$B$2:$B$8,"<19")

      F equal 20 but not more than 24:
      =COUNTIFS($A$2:$A$8,"F",$B$2:$B$8,">=20",$B$2:$B$8,"<24")

      1. Hi Svetlana Cheusheva , Your solution is helping me , Thanks

  22. Hi Svetlana I sent you an email for your assistance could you be so kind to help me? thanks Jason

    1. Hi Jason,

      Have just emailed you the formula, hopefully this is the result you are looking for.

  23. Column B & C data not pasted very well. Just put every second time in column c.

    1. Hello Kees,

      I believe the following formula will work a treat:
      =COUNTIFS(A2:A10,"<6",B2:B10,">="&TIME(5,0,0),B2:B10,"<="&TIME(7,0,0))+COUNTIFS(A2:A10,"<6",C2:C10,">="&TIME(5,0,0),C2:C10,"<="&TIME(7,0,0))

      In your case, the result will be 4.

  24. Help please.
    3 columns. Column A is a number (Day), Column B & C are time.
    Count rows where day number is less than 6 and times in either B or C are between 5:00 & 7:00

    -----------
    A B C
    D T0001 T0002
    1 6:14
    1 6:57
    1 6:58
    1 20:50
    1 23:05
    2 17:47
    2 17:59
    3 6:01
    3 17:46
    5 18:20
    6 7:06
    6 11:50
    6 13:29
    6 13:53
    6 14:57
    6 17:36
    7 10:26
    7 10:32

  25. Column G is "Barcodes". Column J is "Carriers". How can it get the Excel to display "Flexsteel Truck or FedEx or UPS" in column J:J whenever a BX number (for example..BX09225)is enter in G:G?

    Thanks in advance,

    Glenn

    1. Hi Glenn,

      If you want to use only formulas, then enter this one in cell J2:
      =IF(And(G2<>"", len(G2)>2,left(G2,2)="BX"),"Flexsteel Truck or FedEx or UPS", "")

      Then copy the formula across other cells in column J.

      If you want to insert some values in column J, but have these values replaced with "Flexsteel Truck or FedEx or UPS", or something like that, as soon as the code appears in column G, you need a special VBA macro to fulfill this.

      1. Hi,

        I have a query countiff not working. I have a project allocation sheet where column A is resources and B, C, D, E ....are daily dates. I have to allocate project to a resource in column A in other columns by selecting a drop down I have created in Column B onwards. Now I want a summary that how many resources are in a project end of month.

        Suppose 5 resources were allocated Bug fixing project through out the month the formula would now count resources for me it counts the allocations i.e. number of times I allocated bug fixing to resources

        Please help

  26. Hi,
    how can i automatically count or computed in Monday to Sunday data base count as week summary

    1. Hi Rodz,

      Sorry, I cannot follow you. Could you elaborate on the task a bit more, please?

  27. Trying to find a formula that will average only if EACH cell has a value greater than 0 in it; or if the last 3 consecutive months have a value greater than 0. Any help is greatly appreciated.

    1. I believe, you can use a formula similar to this:

      =IF(AND(E2>0,F2>0,G2>0),AVERAGE(A2:E2),"-") where E, F and G are the last 3 months' values. You can add more > operators to the nested AND function if you want to check more than 3 months.

  28. oops, it's not pasting like i want it to. basically, each day is a column, each time is a row. sorry for the confusion.

    1. Hi Svetlana ,

      I 've send sample data Plz help me for get formula

      1. Ma'am,
        I want to how many HBL availbale in sheet against city
        Exmp
        CITY COUMN A COLUMN B
        ALIGARH HBL HBL
        ALIGARH HBL HBL.
        ALIGARH HBL HBL
        ETAH HBL HBL
        ALIGARH HBL HBL
        ALIGARH HBL HBL

        1. Ma'am,
          I want to how many HBL availbale in sheet against city
          Exmp
          CITY COUMN A COLUMN B
          ALIGARH HBL HBL
          ALIGARH HBL HBL.
          ALIGARH HBL HBL
          ETAH HBL HBL
          ETAH HBL HBL
          ETAH HBL HBL
          formate

          cluster name HBL QTY REQUIRED
          ALIGARH
          ETAH

    2. Hi Emily,

      Can you please send me your sample workbook at support@ablebits.com and an example of the result you want to get? I believe in this way it will be easier for us to suggest a formula that returns exactly the result you are looking for.

      1. what is deference between countif and countifs

        1. COUNTIF is intended for counting cells based on a single condition, while COUNTIFS allows specifying several criteria in several different ranges.

      2. Hi Svetlana,

        I just sent the sample workbook. Please let me know if you received it.

        Thank you!!

        Emily

        1. Hi Emily,

          Yes, our support team passed me the workbook this morning and I emailed you the result a few minutes ago. Hopefully, the formulas work as you expected :)

          1. Hi Svetlana,
            I think I have similar problem.
            Would you please publish the solution for use the time as the cretria, something like
            "> 12:00 PM" and "<1:00 PM"
            Regards

            1. Hi Hassan,

              A formula can be similar to this:

              =COUNTIFS(A1:A21, ">"&TIMEVALUE("12:00 PM"), A1:A21, "<="&TIMEVALUE("1:00 PM"))

  29. Hello,

    I have a list of classes with the day and start & end times in one spreadsheet.

    The format looks like this:
    M 8:00 AM - 9:50 AM
    T 12:30 PM - 2:20 PM
    M 9:00 AM - 10:15 AM
    F 7:00 AM - 1:00 PM

    In another spreadsheet i have a table like this one below. I want to know how many classes occur on Mondays between 6:00 am and 6:29 am,6:30 am - 6:59 am,7:00 am - 7:29 am, etc.

    M T W R F
    6:00 AM
    6:30 AM
    7:00 AM
    7:30 AM
    8:00 AM
    8:30 AM
    9:00 AM
    9:30 AM
    10:00 AM
    10:30 AM
    11:00 AM
    11:30 AM
    12:00 PM
    12:30 PM
    1:00 PM
    1:30 PM
    2:00 PM
    2:30 PM
    3:00 PM
    3:30 PM
    4:00 PM
    4:30 PM
    5:00 PM
    5:30 PM
    6:00 PM
    6:30 PM
    7:00 PM
    7:30 PM
    8:00 PM
    8:30 PM
    9:00 PM
    9:30 PM
    10:00 PM
    10:30 PM
    11:00 PM
    11:30 PM
    12:00 AM

    I appreciate your help tremendously!

    Thank you!

  30. Thank you. I just spoke to a colleague who walked me though a pivot table of my data. Thanks again.

  31. Can COUNTIFS can be used to find the number of matches within the same range?

    I have a range of 500 postal codes in one column. These are formatted in two groups of three characters each (i.e. A9A 9A9). The first group of characters will change slightly to represent a different region - A9B, A9C, A9D, etc. I would like to get a count of each regional group.

    I could do this over and over again (as I've already done) as follows:
    =COUNTIF(M1:M500, "A9A*")

    This proved to be very repetitive to copy, paste and modify this 25 times for each of the regional postal code categories I'm working with. Can COUNTIFS do this at one time?

    1. I have the same problem where I want to count how many agents are working between 06:00 AM and 10:00 AM. How can i do that using countif function, send suggestions

      1. Or this :D

        =IF(AND(E2=1,OR(F2>=TIMEVALUE("04:00:00 PM"),F2<=TIMEVALUE("04:00:00 AM"))),1,0)

        1. sorry...was for another comment.

      2. Jeethan,

        You can use a formula similar to this:
        =COUNTIFS(A1:A21, ">="&TIMEVALUE("6:00 AM"), A1:A21, "<="&TIMEVALUE("10:00 AM"))

    2. THANKS VERY MUCH ITS VERY USEFUL FOR ME

    3. Hello Michael,

      Regrettably, COUNTIFS cannot help in your case because it counts cells that meet ALL of the criteria you specify in the formula. You can achieve the desired result in this way:

      Create an additional column and copy the following formula there =LEFT(A2,3) where A is your postal codes column. This formula will extrat the first 3 characters of the codes.

      Then you can proceed in 2 ways.

      Way 1:
      - Sort your table by the postal code column or the newly created column with the above formula.
      - Apply subtotal to the table (Data >Outline >Subtotal) with these settings:
      At each change in : Column with the formula
      Use function: Count
      Add subtotal to: Column with the formula
      - Click Ok.
      - Then Press Number 2 at the left side of you sheet and you will get the count of codes by region.

      For more info about using subtotals please see this article -

      Way 2:
      - Insert a pivot table (select your table and go to Insert > Tables > PivotTable).
      - Place your pivot table onto a new sheet.
      - Drag and drop the column with the formula to the Rows section and the original column with the postal codes to the Values section.

      You will get the same count of codes by region.

      1. sainu says:
        September 26, 2017 at 7:22 am
        Hi Svetlana,

        Could you please help to derive a formula for countif with 2 criteria

        Scenario:-

        cell range name is Date, i need a particular date plus
        another cell range is Method, under method there are 3 options say (SIF Entry, Excel Upload & Bulk), i need count if both criteria meets, my table for the function look like,
        SIF Entry Excel Upload Bulk
        03 sep 2017 Formula comes here Formula comes here Formula comes here
        04 sep 2017

      2. if column A contains numeric value like = 1 2 3 4 5 6 7 8 9 10 etc...
        and column B contains three status like = Ontime, Late & Not Done

        then I want count-if of column A's numeric value 3 and 4 and column B contains status of Not Done

        kindly help me.

        1. =countifs(A:A,">=3",A:A,"<=4","B:B,"Not Done"

          1. Few typos above.
            =countifs(A:A,">=3",A:A,"<=4",B:B,"Not Done")

            1. You could also do:
              =countifs(A:A, {"3", "4"), B:B, "Not Done")

              1. Ignore. minor error.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)