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 4. Total comments: 2050

  1. Hi, I have a spreadsheet that records answers to a series of questions that are submitted by employees. We have 3 shifts per day and each shift might enter 30 to 40 submissions. I have sorted the sheet in to date and time order so that each employee's name appears in "blocks" of entries. For example there might be 35 entries submitted by Fred, followed by 31 entries submitted by John, followed by 39 entries submitted by Sarah etc etc. Currently there are over 27,000 rows of data and growing. There are over 900 shifts (3 per day). What I am trying to achieve is to count the number of shifts carried out by each individual. Unfortunately I don't have access to the time sheets so I need to rely on the spreadsheet I'm working on. Is there a way to count the number of times a name appears as the first entry where there are multiple instances of that name? For example, lets assume that Sarah has done 23 shifts, here name would appear in 23 "blocks" of data, with each "block" containing multiple instances of her name (all in the same column). I can easily count how many submissions Sarah has entered, but what I want to know is how many "blocks" of her name there are. I hope that makes sense :)

    1. Hi! This information is not enough to recommend a formula to you. If you have an additional column in your data where the date or shift number is written, you can count the number of unique values in that column for the employee's name. For example:

      =IFERROR(ROWS(UNIQUE(FILTER(B2:B100,A2:A10="John Doe"))), 0)

      You can find the examples and detailed instructions here: How to count unique values in Excel an easy way. I hope it’ll be helpful. If something is still unclear, please feel free to ask.

  2. Is it possible to use COUNTIF in these?
    Total count of Column A for which the criteria are met without adding extra column C
    [Criteria: IF (DAYS (Column A1, Column B1) > 3, 1, 0)]

    A B
    16/11/2022 20/11/2022
    10/11/2022 14/11/2022
    29/11/2022 01/11/2022
    18/10/2022 10/10/2022
    12/10/2022 04/10/2022

    1. Hi! The COUNTIF function can only use cell references as arguments. You cannot use calculations within it. So if I understand the question correctly, try this formula to find the number of time intervals greater than 3 days.

      =SUMPRODUCT(--(DAYS(B1:B4,A1:A4)>3))

      I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more detail.

      1. Hello. Is it possible to use in this criteria: IF (NETWORKDAYS.INT(Column A1, Column B1,16) > 4, 1, 0)?

      2. Hello! is it possible to use SUMPRODUCT with this [Criteria: IF (NETWORKDAYS.INTL(WORKDAY.INTL(Column A1,1,16), Column B1,16) > 3,1,0]

          1. [Criteria: IF (NETWORKDAYS.INTL(WORKDAY.INTL(A1:A4,1,16), Column B1:B4,16) > 3,1,0]

  3. I need a formula to find only cells in Column B(Amount) that adds up to Zero for each criterion in Column A(Reference)

    Reference Amount
    A97024 -57.73
    A97024 1924.28
    A97024 -1924.28
    A97047 -893.16
    A97213 229.65
    A97213 -5569.68
    A97213 5340.03
    A97227 251.49
    A97227 -3025.38
    A97227 2773.89
    A97232 -7.49
    A97232 249.79
    A97232 -249.79
    A97244 229.65
    A97244 -5569.68
    A97244 5340.03
    A97290 -1314.56
    A97358 -9.39
    A97358 156.43
    A97358 -156.43
    A97439 4208.14
    A97439 -8474.05
    A97439 4265.91
    A97459 -3.41
    A97459 -56.79
    A97459 3.41
    A97459 56.79

      1. Thanks @Alexander for the prompt response. It was really helpful

  4. Hi,
    I have a (very large) table with the following entries for each row:
    name_of_applicant date_birthday date_application

    I am trying to count all applications, where both of the following criteria are true:

    1. all that have applied after a certain date, e.g. the 2022/01/01
    2. the person was at least 16 years old at the day of the application

    I cannot change the table itself or add auxiliary entries.

    The first part (application after...) is no problem, but I can't figure out how to combine it with the second criteria.

    Thanks for your help!

  5. I have a sheet I am working on with dropdowns. I have fir example column E3:E63 has a dropdown box of new, used, pending or purchase. I need a formula to count say the "new" as 1, but in column F3:F63 I have a dropdown with employee names, so if a persons name is selected I need it subtract .5, if no name is selected or "no" then it can stay as 1. Not to add in addition to, but to just remain 1. If that makes sense?
    To give you the scenario, I sell cars for a living. So, when I track my sold units I have a dropdown that tells me if it was a new car, used car, pending or a purchase. In the next column, (F) if I had to split the sale with an employee and I select their name I need it to subtract .5 from the new car or used car etc. I can count it as a whole number using the =Countif(E3:E63, "new") and it tallies a 1 in the "new units sold" section, but if it happens to be a split with another employee in column F3:F63 I need it to subtract .5. Is this possible, and if so, what is the formula? I have been trying to figure this out for 2 months and cannot get it!

    1. Hi! The COUNTIFS function can be used to find the sum of multiple conditions. For example,

      =SUMIF(F2:F10,"",E2:E10)+SUMIF(F2:F10,"no",E2:E10)+SUMIFS(E2:E10,F2:F10,"<>",F2:F10,"<>no")*0.5

      You can also use the SUMPRODUCT function to find the sum of multiple criteria.

      =SUMPRODUCT(E2:E10,0.5+0.5*(ISBLANK(F2:F10)+(F2:F10="no")))

      I hope it’ll be helpful.

    2. I'm sure others will provide a better answer but what I would do is create a formula in column G that that basically says that if F is not blank (meaning it includes a sales person's name with whom you'll split the sale with) then return .5, otherwise 1. =IF(F3="",1,0.5) copy this down to F63. then you can just sum those numbers together to get you the total units sold including split sales.

  6. In the tutorial above, there is an example that counts orders with the status "Cancelled" or "Pending" or "In transit". The provided formula is:

    =SUM(COUNTIFS($C$2:$C$11, {"cancelled", "pending", "in transit"}))

    However, I’m interested in having the "cancelled", "pending", "in transit" portion of this formula contain a cell reference to this text. Something like:

    =SUM(COUNTIFS($C$2:$C$11, {$D$2})) where cell D2 contains "cancelled", "pending", "in transit".

    Any suggestions on how to get it to work?

    1. Hi! You can write the conditions in three separate cells and use a COUNTIFS formula like this:

      =SUM(COUNTIFS($C$2:$C$11, D1:D3))

      If you write all the conditions in one cell and separate them with spaces, use the TEXTSPLIT function to split the criteria:

      =SUM(COUNTIFS($C$2:$C$11, TEXTSPLIT(D1,," ")))

      I hope my advice will help you solve your task.

      1. Alexander, thank you so much. The TEXTSPLIT function was exactly what I needed. Definitely keeping that one in my back pocket for future use. Have a great weekend!

        1. One last question. In the example above the TEXTSPLIT worked great. How could I alter your suggestion to count excluding those three text items? I was thinking this might work but apparently I was wrong.

          =SUM(COUNTIFS($C$2:$C$11, ""&TEXTSPLIT(D1,",")))

            1. Thank you. I was offline for the last 10 days but will have a look at this later today. Appreciate your help :-)

  7. Hello, I am trying to count how many colours are in a row of data cells e.g. Red, Green, Green, Yellow would be 3 colours. When I use SUM(COUNTIFS variables it says 4 because it is adding all colours. Is there a way to count only how many types of colours there are?

      1. Thank you. I have tried a few of those formulas and can't figure it out.

        Artem A Set1A Set1A Set1B Set1B Set1C Ditties Set1C

        I need it to count how many times it says Set1A, Set1B, Set1C and Ditties in this example above. Because each row needs to be calculated differently as they are different start points, I am struggling to do it per row and not across the whole page of data like the examples show.

        1. Hi! As far as I can see from your second comment, your task is now different from the original one. You are asking a very different question from earlier. To count "how many times it says Set1A", use COUNTIF formula. For example:

          =COUNTIF($A$2:$L$2,C2)

          If this is again not what you need, give an example of source data and write the desired result.

  8. Hi,

    I am wanting to find the sum of all cells which have a specific value in the same row.

    I am currently logging teaching hours in a sheet and using a drop down in column D to select which class I am teaching (class A, class B, class C), then the amount of hours (1.5, 3, 4.5) in column G. Is there a way to add only the cells next to a specific class? So I can see a total number of hours for each specific class?

    Thanks

      1. That's perfect, thank you :)

  9. I'm trying to do a countifs with multiple text criteria, to breakdown how many sales were done by an individual from a particular lead source

    As an example
    John doe
    how many were organic
    how many were self generated

    Jane doe
    how many were organic
    how many were self generated

    Can you please help?

    1. Hi! I hope you have studied the recommendations in the tutorial above. It contains answers to your question. If this does not help, explain the problem in detail.

  10. I'm trying to have a formula that counts a student when two conditions "English" and "Graduated" are true, but I keep getting an error. I am trying to pull information from another sheet. Below is the formula I've been trying to use:

    =countifs(‘Sheet2’!A2:A,”English”,B2:B,”Graduated”)

    1. Hi! The COUNTIFS function can only correctly calculate values for a condition on one sheet in one Excel spreadsheet. Please read the above article carefully.

  11. I need to write a fomula that counts the UPC codes that were used in Las Vegas. There is a mixture of blanks and with letters. Here is a similar example:

    Location UPC Codes
    Las Vegas 981
    Los Angeles 8989
    Tokyo 9867
    Las Vegas 8989
    Los Angeles 8989
    Tokyo
    New York 65464
    Miami Pi757
    Las Vegas
    Los Angeles 8989
    Tokyo 2165
    New York
    Miami 235
    Las Vegas 8989
    Los Angeles G192
    Tokyo Pi757
    New York 8989
    Miami 8989

    1. Hi! Please check out this article to learn how to count unique values in Excel: with criteria, ignoring blanks.
      Try to use this formula:

      =IFERROR(ROWS(UNIQUE(FILTER(B2:B20,A2:A20="Las Vegas"))), 0)

  12. I need to identify the presence of an element in at least one column, in columns that are separated from each other, but I need to count it just once (even if it is in several columns).
    For example, in column A I have attendance on day X; in column D I have the attendance for day Y and in column H I have the attendance for day Z. Each day is marked "Yes" or "No".
    I need to count the people who attended, regardless of whether they went 1, 2 or 3 times. When using the countifs function, if the person was not there on a day, it doesn't count them. On the other hand, if I combine the countifs function and add what is derived from the Or function, then it counts it 1, 2, or 3 instead of 1. Is there a way to do it?

  13. DATE SALESMAN PRODUCTION HORECA
    01-Oct-23 KOUSHAL JOSHI FOLLOW UP
    01-Oct-23 NEERAJ PARIHAR CLOSED
    01-Oct-23 RAFIQ SHEIKH FOLLOW UP FOLLOW UP
    01-Oct-23 KOUSHAL JOSHI FOLLOW UP FOLLOW UP
    01-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
    06-Oct-23 RAFIQ SHEIKH FOLLOW UP
    06-Oct-23 KOUSHAL JOSHI FOLLOW UP FOLLOW UP
    06-Oct-23 RAFIQ SHEIKH CLOSED CLOSED
    09-Oct-23 NEERAJ PARIHAR FOLLOW UP FOLLOW UP
    10-Oct-23 KOUSHAL JOSHI FOLLOW UP FOLLOW UP
    10-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
    10-Oct-23 RAFIQ SHEIKH FOLLOW UP
    13-Oct-23 KOUSHAL JOSHI FOLLOW UP FOLLOW UP
    14-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
    15-Oct-23 RAFIQ SHEIKH FOLLOW UP FOLLOW UP
    15-Oct-23 KOUSHAL JOSHI FOLLOW UP FOLLOW UP
    15-Oct-23 NEERAJ PARIHAR CLOSED CLOSED
    15-Oct-23 RAFIQ SHEIKH FOLLOW UP FOLLOW UP

    Need to know that which sales man has generated how many leads in production and HORECA on daily basis. Required daywise report

    1. Hi! I can't guess what result you wanted to get. Please provide me with an example of the expected result.

  14. Hi, i have a question about a seemingly simple function but i cannot get it figured out.

    So this is the formula i have

    =COUNTIFS(I:I,"",D:D,"DEPO",B:B,"2024FA")+COUNTIFS(J:J,"86",D:D,"DEPO",B:B,"2024FA")

    Now, the context is that i need to count a person whether they have either any value in Column I, or a value of 86 in Column J as well as the criteria for columns D and B staying the same. People CAN have both values present. The way the formula is written now, if someone has both values present, they are counted twice.

    Am i missing something? I thought of using an OR function, but i cannot get that to work. Anyone have any insight into this?

    Thank you!

    1. Hello! Subtract the number of people who have both values present. Try the formula:

      =COUNTIFS(I:I,"",D:D,"DEPO",B:B,"2024FA")+COUNTIFS(J:J,"86",D:D,"DEPO",B:B,"2024FA") - COUNTIFS(I:I,"",J:J,"86",D:D,"DEPO",B:B,"2024FA")

  15. Hi! I'm trying to count a range of cells across a large array; *if* they match the criteria in a single column,
    so, my first through was; It should be as simple as

    =COUNTIF(B3:B123, "A Shift", F3:HH123, "Assigned"),

    now; if i'm understanding correctly; the the vertical range must be the same size;
    Is failing because the horizontal range is larger?

    If so; what's the solution to simply find

    if x=a in a single vertical column, count how many occurrences on the horizontal =b

    I've tried

    =IF(B3:B123=A, COUNTIF(F3:HH123, "Assigned"),0) and that wants to spill to nearby cells;

    What am I missing here?

    1. Hi! If I understand your task correctly, to count the number of values across multiple criteria, try using the SUMPRODUCT function. Here is an example formula:

      =SUMPRODUCT((B3:B20="A Shift")*(F3:M20="Assigned"))

      I hope it’ll be helpful.

      1. Thanks for the speedy reply;
        Unfortunately that example is returning 0

        For what i'm trying to do, I have Column B which is just "A", "B", and "C" about 20 times each as we go down the rows from 3 to 123;

        Then I have a matrix going across all the way from Column F to Column HH,

        Some of the cells have dates in to indicate when a task completed; and some contain just the word "Assigned";

        I'd like to count how many occurances of "Assigned" appear across the range where column B="A", then once that's working follow on for rows where Column B="B" and where Column B="C"

        I originally used
        =COUNTIFS('Primary Matrix'!F3:T30,"*Assigned*") to count the rows where Column B="A"

        but this would mean that someone will have to manually adjust the formula whenever a new person is added to the range where B="A"

        So rather i'd like to create a formula that will sum all occurrences of "Assigned" between Columns F and HH; only IF column B="A"

        So i've tried your example like this, and I can see how it should work;

        =SUMPRODUCT((B3:B123="A")*(F3:HH123="*Assigned*"))

        But it returned 0 across a range that does contain multiple occurences of "Assigned", and I feel like i'm missing something obvious; but I can't work out what.

        1. Hi! The formula I sent to you was created based on the description you provided in your first request. However, as far as I can see from your second comment, your task is now different from the original one.
          To learn how to find a partial text match, please read: How to find substring in Excel.
          For example:

          (ISNUMBER(SEARCH("Assigned",F3:HH123)))

          1. Hi,

            I'll give that a go;

            Apologies if it was unclear; the task has always been: count number of "*Assigned*" in a range; only where column B (outside of that range)="A*", and ignore other instances (within the range) of "*Assigned*"

            1. So, I've found a workaround;

              I wanted to avoid adding any additional columns to the page with the data;

              but by doing a single column with just

              =COUNTIF(F3:HC3,"*Assigned*")

              after the final data column; then all I had to do was (on the page I wanted to display the data)

              =SUMIF('Primary Matrix'!B:B,"A*",'Primary Matrix'!HF:HF)

              and likewise for B, and C.

              that's solved it; not how I wanted to solve it; but it unarguably works now.

              1. *A single column, with that COUNTIF repeated for each row of data.

  16. =COUNTIFS('Section 2'!$AC:$AC,"Pending",'Section 2'!$AA:$AA,">12 months")

    I am trying the above formula to get the number of cases pending beyond 12 months, as per my data sheet the result of this formula should be 0. however, the formula is returning a value i.e. 1 in first instance & 2 in second instance.

    When I removed the > sign, I got the desired result. Also, when I tried adding >12 months in my data sheet as a dummy value to test the formula, it did not return the correct number. why is that so?

  17. I am trying to incorporate the today function into my countifs formula. I have a column that reflects the date of activity but I can't seem to get it right.

    =COUNTIFS(Master_TTHU_Inventory!$H$2:H$5000, A4,Master_TTHU_Inventory!$G$2:$G$5000,"MISSION READY")

    The above formula is for my grand total report, but I need to show daily totals for cob that day on a separate sheet using the same information.

    1. Hi! Create a column with dates on a separate sheet. Then add a condition for the date to the COUNTIFS formula. For example:

      =COUNTIFS(Master_TTHU_Inventory!$H$2:H$5000, A4,Master_TTHU_Inventory!$G$2:$G$5000,"MISSION READY", Master_TTHU_Inventory!$D$2:$D$5000,New_Sheet!D2)

      D - column with dates.
      You can get a report without formulas, using a pivot table with grouping by days. Read more: How to make and use Pivot Table in Excel.
      I hope it’ll be helpful. If something is still unclear, please feel free to ask.

  18. I appreciate a lot to the information provided above. We are learning. However, I am still not clear on something I dont know which formula works best for the following example.

    A B C
    Month Dept Service Requested

    1 Jan-23 Sales 0001
    2 Jan-23 Sales 0001
    3 Jan-23 Sales 0001
    4 Jan-23 Operations 0001
    5 Jan-23 Accounts 0002
    6 Jan-23 Operations 0002
    7 Jan-23 Accounts 0002
    8 Jan-23 Admin 0003
    9 Feb-23 Accounts 0004
    10 Feb-23 Sales 0004
    11 Mar-23 Accounts 0005
    12 Mar-23 Operations 0006
    13 Mar-23 Sales 0007
    14 Mar-23 Operations 0008
    15 Apr-23 Admin 0009
    16 Apr-23 Admin 0010
    17 May-23 Admin 0011

    I want to count "how many service types were requested by each department per month". This means the formula has to count the similar service type once for same dept in the same month right.

  19. I am using this formula and it is generating an incorrect value. =COUNTIFS('Tray Audit Log'!D:D, "Y",'Tray Audit Log'!B:B,">6/1/2023") - COUNTIFS('Tray Audit Log'!B:B,"<6/30/2023"). The data is counting 641 when there are actually 194 yes in the month of June.

    I am trying to count the total y(yes) from one column and the MONTH from another column all information on a different tab. I can send the data via email I cannot attach it to this chat.

  20. I want to compare multiple dates for Planning dates vs. Actual dates; it seems that in planning dates there are several activities inclusion same with actual dates. I need to compare it 1 by 1 activity date and the true values will determine the condition of green, amber and red.

    1. Hi! Please clarify your specific problem or provide additional information to understand what you need. Give an example of the source data and the expected result.

  21. Any way please to get the function criteria at countifs from a cell with multiple values into a criteria like {"A,", "B", "C") automatically?
    A B D E
    Item1 London PART DEPOT
    Item1 London Item1 Frankfurt
    Item2 London Item2 Hong Kong
    Item1 Heathrow Item1 London
    Item2 Manchester Item1 London, Manchester
    Item1 Sandwell Item2 London, Manchester, Glasgow
    Item1 Glasgow
    Item2 Glasgow
    Item3 Frankfurt

    For example I need a =sum(countifs(A:A,D6,B:B, {"London", "Manchester","Glasgow"}) next to E6.
    E6 is London, Manchester, Glasgow separated by comma.
    any quick way to write the function so I can reference this cell but in a way it turns into {"London", "Manchester","Glasgow"} within the function instead of me typing it out?

    1. Unfortunately, the COUNTIFS function does not work with array formulas. You can write an array of values directly in a formula, but you cannot pass an array of values to a COUNTIFS formula using another function.

  22. Can we use countifs in MS Excel with in different online sheets...

  23. Hello,

    I have tried using one of your formulas but I might have an incorrect understanding of it.

    I am trying to count multiple criteria (frequency of the word "CVD" tagged to "Antipolo DC")

    I try to use this formula =COUNTIFS(N3:N2028,"Antipolo DC",Y3:Y1048576,"CVD") but the results show #Value!

    May I kindly check what I am possibly doing wrong?

    Please note that Antipolo DC is a location (there are 20 other locations in the list) and CVD is an option (there are 5 other options in the list)

    1. Hi! I have said many times on this blog that the sizes of all ranges (that is, the number of rows and columns) in the COUNTIFS and SUMIFS functions should be the same.

  24. Hi,
    I am wanting to know if there is a formula on excel that would give me employees working at a given period per day. For example - there is a total of 20 people working at the facility but they all start and finish at different times. I want to know how many people are working from 9am to 10am etc etc. hope this makes sense.

    Thanks

    1. Hi! The answer to your question can be found in this paragraph of the article above: How to count numbers between 2 specified numbers. Count the number of values greater than the start time and less than the end time. I can't offer you a formula as I don't have your data.

  25. Hello, I cannot figure out what formula to use for this problem. Referring to the data set below... Let's say column A is an employee number and I need to count all of the Ns for that employee, how would I write that formula? The other issue is the number of rows for each employee will not always be the same. For example, employee 1260 may have 7 rows, employee 1266 may have 12 rows, employee 1279 may have 15 rows.... so the range will always be different. The next issue is that the spreadsheet has 115311 rows so I cannot individualize each formula with the employee number or range. The formula would need to find each unique employee, establish the range and then count the number of Ns or Ps or whatever within that range. I was trying the =countifs formula trying to get it to use whatever number is in A1 as Criteria1, then giving the next range and asking it to count the Ns. =COUNTIFS($A2:$A115311,"=A2", C2:I27,"N") ..... this formula did not work. LOL

    Not picky if it is displayed on a separate sheet. If its easier, it could put the report on a separate sheet which would list the unique employee number followed by how many Ns, Ps, 7s, As, etc.

    1260 4/2/2023 N N N N 7 N N
    1260 4/9/2023 N 7 N P N N N
    1260 4/16/2023 N N N N N A Q
    1260 4/23/2023 A P N N N A N
    1260 4/30/2023 7 N N A A A Q
    1266 5/7/2023 N N A N N N N
    1266 5/14/2023 N N A A P 7 N
    1266 5/21/2023 N P N A A A Q
    1266 5/28/2023 N N N N N N N
    1266 6/4/2023 N N N A A Q N

    Thank you for any help you could offer!

    1. Hi! Read the instructions above carefully. Also note that all ranges in the COUNTIFS function must have the same size, i.e. the same number of rows and columns.

  26. A need Help for All Apples count and only show Delivered Percentage
    if i use this code "=COUNTIFS($A$2:$A$11, "Apples", $C$2:$C$11,"Delivered")" its show (Apples Delivered 3) . if i had total 10 Apples and Delivered only 3 it will show Apples Delivered 30 %.

  27. Thanks for the information.

    I would like to count the number of unique value based on a set of "OR" & "AND" criteria.

    Given the following,
    A 3366 1 0
    A 3329 1 1
    B 2282 1 1
    B 2282 1 1
    B 2282 0 1
    B 3409 1 0

    To count the number of unique value of column B with following criteria: column A = "B" AND column C = 1, I could get the answer with
    ={SUM(IF((A1:A6="B")*(C1:C6=1),1/COUNTIFS(A1:A6,"B",C1:C6,1,B1:B6,B1:B6)))}

    How to add an "OR" condition to the criteria for this?
    say I would like to count the number of unique value of column B with the following criteria: column A = "B" AND ((column C = 1) or (column D = 1))
    of course apart from generating a new column E to do the logic.

    Thank you.

  28. I'm wondering if it's possible to count selected cell with conditional formatting with a date. counting the following
    A5 + A8 +A10

    each cell draws information using lookup formulas and conditional formatting

    A5 = date (01/05/24)
    A8 = date (26/09/22)
    A10 = Txt (not trained)

    = number of cells greater then TODAY()
    this example = 1

  29. Hello all, this is a fantastic site, I've learned so much, can't tell you! OK, I can't seem to figure out how to do this, it seems simple, I must be missing something.
    I want to count cells that have certain text strings within the cell that has a whole bunch of words in it. So let's say I've got a whole bunch of cells that contain sentences like this:

    Mary went to the store to get apples
    James went to the store to get oranges
    James went to the store to get apples

    etc., etc.

    I want a formula that will count how many cells contain both "Mary" and "apples". I've tried the following, but they don't work:

    =COUNTIFS($A$1:$A$10,*Mary*,$A$1:$A$10,*apples*)
    =COUNTIFS($A$1:$A$10,"Mary",$A$1:$A$10,"apples")

    Do I need to use the AND statement? Or maybe there's an issue searching for the words in the cell?

    Thanks all.

    Tom

    1. Add quotation marks to the text string. Try this formula:

      =COUNTIFS($A$1:$A$10,"*Mary*",$A$1:$A$10,"*apples*")

      Please have a look at this guide: How to find substring in Excel. For example:

      =SUMPRODUCT(ISNUMBER(SEARCH("apple",A1:A10)) * ISNUMBER(SEARCH("mary",A1:A10)))

      I hope it’ll be helpful.

      1. This is perfect, thank you so much for replying, much appreciated!

        Tom

  30. This formula counts 5 occurrences of 'X' or more than 5 'X' as 1 and it also does not count lower case 'x' and it is good. But, how can I modify this so that it will not count interrupted appearance of 'X' in a row but only unbroken 5 'X' or XXXXX? Broken and interrupted is like this ( XXXX X, XXX__XX and others) =SUM(IF(MMULT(--(EXACT(F8:AK39, "X")), TRANSPOSE(COLUMN(F8:AK39)^0)) >= 5, 1, 0))

  31. =COUNTIFS('Sheet1'!$C$2:$C$29586,">="&'Safety Event'!C$1,'Sheet1'!$E$2:$E$29586,"=Near Miss*",'Sheet1'!$BP$2:$BP$29586,"SSS 05:00*",'Sheet1'!$C$2:$C$29586,"<="&'Safety Event'!C$2)

    Can you add more on top of "SSS 05:00*"? I have to add more 6 items to count. or can we just slot a table range instead?

    To count lets say from July 2, 2023 (C1) to July 8, 2023 (C2) to count ---- if Column E2:E9586 is showing a text Near Miss* miss and column BP is showing the text SSS 05:00* ( I want to add more shift aside from SSS 05:00)

  32. Not really a comment although I loved the info and was able to use it in a spreadsheet I keep active with a group of 9 golfers and therein lies my question...
    I have been trying for over a month now to auto copy data in a column of cells to another column, next to it. The data in the first column changes frequently, sometimes 4-5 times a week. What I need to do is copy the data in the first column into the second column before the first column is overwritten by the data entered on any given day. It's a small table that tracks a golfers drives (distance on each hole). I am trying to keep track of their last 5 rounds but can't figure out how to shift everything over 1 column before the new data overwrites in the first column. HELP!!!!

  33. Hi, Needed help using the COUNTIFS formula with conditions, essentially I want to be able to count the number of times any initials from the data below features in the data set below, based on the region, month and if it is H&S/Commercial. I.e I want to be able to count the number of times text appears in May for H&S, for the North Planned region and similarly the number of times text appears in May-23 for Commercial. The list of names that will appear is roughly 11-12 (I can use a wildcard for the total times text appears for that particular month but can't get it to work when trying to get it for just H&S/Commercial:

    May-23
    Week Commencing 01-May-23 08-May-23 15-May-23 22-May-23 29-May-23

    H&S Commercial H&S Commercial H&S Commercial H&S Commercial H&S Commercial

    Region Contract

    North Planned Guinness - PM LH
    Wrexham - Voids SR
    Wakefield - External Works PCSA Stage
    Sheffield City Council - Sheffield Adaptations
    Leeds CC - Back to Backs
    St Leger - Towers
    Oldham - PFI
    St Leger - New Capital Framework
    Kirklees Lot 1
    Sheffield High Rise
    FCHO
    Guinness SHDF
    Incommunities
    Guinness SHDF Wave 2
    Places for People
    Together Housing
    SCC Acquisitions

  34. Last attempt at this.

    Sorry for the spam, but this message system is posting stuff I'm not typing and not posting stuff I am.

    I have a datasheet and then a stats sheet, I'm trying to populate the Stats sheet automatically from data entered into the data sheets based on a monthly period.

    Jan, Feb, Mar etc.

    My formula is a COUNTIFs which first checks outcome column for the word "Positive NR" then it checks the Date Column for dates ">=" and "="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"<="&Data!A2)

    1. Yeah its done it again. Cannot send you my formula, but believe me the ones which are working and the ones which doesn't are identical other than the "Positive" and "Positive NR", so cannot work it out.

      1. Hi! Study carefully the last paragraph in the article above. Here is an example of the formula:

        =COUNTIFS($I:$I,"Positive",$A:$A,">="&A1) - COUNTIFS($I:$I,"Positive", $A:$A,">="&A2)

  35. Hi,

    I'm trying to create a spreadsheet for work which will calculate the statistics for each month throughout the year based on another spreadsheet we use to hold all the data.

    So we have a column with received date, a column with District and another column with an outcome.

    What I'm trying to do with limited success is Check "Date Received" column for any dates within each month, then check another column with those dates which matches 1 of 5 words added to that column.

    Example 1:

    Column A - Check for all Cells with Dates between and including 01/01/2023 to 31/01/2023.
    Column C - Check for all Cells with Text containing exactly "POSITIVE".

    Below my Formula (I have a separate datasheet hidden on the workbook which contains all my month dates).

    =COUNTIFS('[SS Stats 2023.xlsx]2023'!$I:$I,"Positive",'[SS Stats 2023.xlsx]2023'!$A:$A,">="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A23,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"<="&Data!A2)

    Any assistance on this would be great, as its driving me up the wall right now, it should work and I cant see why it doesn't :(

    1. Hi! Pay attention to the last paragraph of the article above: Count dates with multiple criteria. Count the values where the dates are greater than the start date, subtract the values where the dates are greater than the end date.

    2. Welp same issue again.

      =COUNTIFS('[SS Stats 2023.xlsx]2023'!$I:$I,"Positive",'[SS Stats 2023.xlsx]2023'!$A:$A,">="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A23,'[SS Stats 2023.xlsx]2023'!$A:$A,"="&Data!A1,'[SS Stats 2023.xlsx]2023'!$A:$A,"<="&Data!A2)

      1. Ok I give up, it wont let me post my message or any variation of it, and all it does is make it look like my formula is massively wrong when the above formula has some "=" statements inbetween the ">=" and "<=" statements. I dont know how to fix it.

  36. I'm trying to do =COUNTIF(B:B, C:C-9) and it's not working.
    How do i get around this?

    1. Hi! I don't really understand what you want to calculate. But the arguments to the COUNTIF and COUNTIFS functions cannot be formulas. They can only be values or cell references. Read the article above carefully.

  37. Hi
    I am trying to write a count if formula to count between two dollar figures...which appear

    C4-DB4 is a run of varying $ amounts
    DE4 is the max value (FORMULA)
    DD4 is 10% less than max value (FORMULA)

    =COUNTIFS(C4:DB4,">=DE4", C4:DB4,"<=DD4")

    The above forumla wont count the number of $ values between max and 10% discount. Please help!

  38. Hello,

    I'm trying to write a formula that uses data from different cells based on where today's date falls within a date range. This is what I have:

    =IF((AND(TODAY()>=DATE(2023,6,1),TODAY()0,CPEP!A9),"")

    Obviously, this isn't working. Any ideas?

    1. =IF((AND(TODAY()>=DATE(2023,6,1),TODAY()0,CPEP!A9),"")

      1. I don't think it is showing the full formula.

  39. Thanks for the information it helped me a lot, I Tried to combine cells as a cross criteria search.

    =COUNTIFS(D$1:D$94,D101,J$1:J$94,"X")

    The " X " Mark means was punched on a different Day (Monday,Tuesday, etc) for Example if Cell J1 has mark and Value D101 is in the range criteria, it will count, but only if both met the criteria ( values and X mark).

  40. Hi,

    Is it possible to tag a progress with each cell containing different data?

    The information will be tagged as "complete" if either "email", "mobile no.", or "address" is provided. It does not necessarily need to have all the information (at least one of the 3 should be fine)

    Thank you!

    Steve

  41. Hi Alex... Im suffering here...

    I need to count how many F there are in multiple colums

    If I count the "F" in one column, works great:
    =COUNTIFS(A:A,"JUNE",B:B,"F")

    but what i really need is to count the "F" in multiple columns:
    =COUNTIFS(A:A;"JUNE",B:K,"F")

    and it doesnt work, what am I doing wrong? is there a way I can do this?

    any help, will be appreciated.

    thank you! claudia

    1. Hello! All the ranges you use in the COUNTIFS function must be the same size. That's why your formula doesn't work. I recommend reading this article: Excel COUNTIF and COUNTIFS with OR logic.
      Here's an example of the formula:

      =COUNTIFS(A:A,"JUNE",B:B,"F") + COUNTIFS(A:A,"JUNE",C:C,"F") + COUNTIFS(A:A,"JUNE",D:D,"F")

      1. oh... got it..that is what i was afraid of... i didnt want to make the formula too long...
        thank you so much, let me check that part of the article again!

        thank you, Alex!!

  42. I have list of trainings in rows and completion status in columns against the resource. How can I use COUNTIF formula to see number of resources who have completed / in progress for each training? Kindly help

    1. If the formulas and examples in the article above don't work for you, give an example of the source data and the desired result.

  43. is something like this possible?

    IF(COUNTIFS(R2,"value1*",S2,"status1"),"aaa","bbb"),IF(COUNTIF(R6,"value2*"),"aaa","bbb")

    or

    IF(COUNTIFS(R2,"value1*" OR "value2",S2,"status1" OR "status2" or "status3"),"aaa","bbb")

    Thanks

  44. Why do I get an error message with th3 following excel formula?
    =IF( COUNT(B90:C90)=2,MOD(C90-B90,1)*24,0)
    The error message only shows up after the date is added in Column A. Start time is column B and end time is column C.
    Thank you!

    1. Hi! I can't check your formula because I don't have your data. An error is possible if the cells contain text but not time. Also, I can't guess which error message you see. Note that there is no reference to column A in the formula.

  45. Hello Dear Team,

    I have an question that is possible to count three or four things with a single formula against every value as shown in the data:-

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 P H A L s/l
    P P P P P H P P P P P P H P L L P P P H P a a P P P H S/L S/L P P 21 4 2 2 2

      1. i want to count total no. of P,H,A,L and s/l with a single formula from the given data.

        1. Hi! If I understand the question correctly, the formula might look something like this:

          =SUM(COUNTIF(A1:T1,{"P","H"}))

          1. Thanks a lot Sir,
            Actually I want to count all P in column "P"
            Count of all H in column H at the end and all L,S/l in their respective column simultaneously with a single formula
            e,g: total P=24
            Total H=5
            Total L-3
            Total S/l=2

  46. Thank you so much, I coundn't remember how to use more then one formula on the same cell and somehow this was the only post that used the + to help me count more then one different word into the same cell.

  47. Hi alexander,
    I have two column of products and I need to find out if a certain brand of a retailer is offered at the other retailer in the other column. Offered by 'retailer ' 'yes' = 1, if not offered then = 0
    is it possible to find out if a brand is offered in the other column without using a specific wildcard? otherwise the wildcard will have to be changed per product and this would not be possible.

  48. Hi, I got small problem.

    I cannot find a way to formulate a suitable formula. I hope you can help me.

    I have to count how many of the people who worked on the DON project were between the 16 and 24 years, male, from China. I need to include all of this as of 12/31/2015. Most important is fact that some of people quit work before that date so I need to exclude them.
    Start of contract is between C3 to C100, end of contract D3 to D100, Birth date E3 to E100, country of residence is F3 to F100, project name is G3 to G100, gender I3 to I100.

    I made it as per the formula below, but I don't know how to count the age bracket correctly (between 16 and 24 years) and eliminate people who finished work before this date (12/31/2015).
    =COUNTIFS(C3:C100, "<=12/31/2015", F3:F100, "China", G3:G100, "DON", I3:I100, "M", )

    TIA John

    1. Hello!
      The COUNTIFS function cannot use other functions or formulas as arguments. Therefore, I recommend using the SUMPRODUCT function.

      =SUMPRODUCT(--(C3:C100<=DATE(2015,12,31)), --(F3:F100="China"), --(G3:G100="DON"),--(I3:I100="M"), --(DATEDIF(E3:E100,TODAY(),"y")>=16), --(DATEDIF(E3:E100,TODAY(),"y")<=24))

      You can also find useful information in this article: How to calculate age in Excel.

  49. Hi Alexander,
    Im a new user, how do I express eg that the Yes must relate to the occurrences of LS rather than any Yes that appears in the column.
    =COUNTIF('Action Log'!G23:G83,"LS")-COUNTIFS('Action Log'!I23:I83,"Yes")
    TIA Karen

    1. Hi! If both of your conditions must be met simultaneously, use the COUNTIFS function to calculate the quantity of values. Read this article above.
      Try this formula:

      =COUNTIFS('Action Log'!G23:G83,"LS",'Action Log'!I23:I83,"Yes")

  50. I am trying to incorporate wildcards into a COUNTIFS with three criteria because the data is coming from a sharepoint and sometimes includes date and time and sometimes only date and I need to look only at dates. So far this is what I have.

    =COUNTIFS('WT Outflow Import'!B:B,$B$4,'WT Outflow Import'!A:A,C18,'WT Outflow Import'!C:C,$B$6)

    B6 is the cell containing the date.

    The above formula returns what I need if there is no time present with the date in the cell. Otherwise it returns nothing as expected. I need the value matches regardless of whether there is date/time or just date. This is a sharepoint connection, so I don't have the luxury of just changing the data.

    I tried using a wildcard and it also returns nothing.

    =COUNTIFS('WT Outflow Import'!B:B,$B$4,'WT Outflow Import'!A:A,C18,'WT Outflow Import'!C:C,$B$6&"*")

    Any idea where I am going wrong here?

    1. Is it because the column where I am parsing using the wildcard is a date (number)?

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 :)