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 57. Total comments: 2074

  1. Hi there - hoping you can help please!

    I have two columns

    Total Sessions Location

    1 S

    10 B

    5 S

    6 B

    what is a countifs formula to reference the location and return and count the sessions please?

    many thanks

    1. hi i am stuck in a prob.
      i want to count the two digits numbers in a given data.
      i applied =ccountif(RANGE,LEN(RANGE)>2)NOT WORKING

    2. Hi KC,

      If my understanding of your task is correct, you need a SUMIF formula rather than COUNTIF. For example, the following formula will pick all "b" locations in column B and return the total of corresponding sessions (column A):

      =SUMIF(B:B,"b",A:A)

      In your example, the result will be 16. If you are looking for something different, please clarify.

  2. I am trying to use countif to return a value of less than or equal to 15 for a range of cells in column A. It keeps returning a zero result. My formula looks like this : =countif(A3010:A3190,"<=15"). Does it matter that my A column is actually a formula that is resulting in the numbers being displayed?

  3. I have a set of customers and their ages in the Rows. In the Column section, I have a set of ranges from: <12months, <36months, <3years, 3 and <7years, 7 and <17 years, 17 and <40years. I want to add a "1" down the columns for each customer that is <12months, or less than 3 years, etc...Then I want to count how many of them are in that age group and get the total for each age range. May you help me please?

  4. Hi There,

    I have tried multiple functions and nothing works!! I have tried COUNTIF, COUNTIFS, SUMIF, SUMPRODUCT and I cannot get the result I need!

    can you help.

    I am trying to count the number of cells which contain a certain Text before a date.

    I used this formula to calculate all cells within a month that belong to date
    =SUMPRODUCT(--(MONTH(J6:K1000)=11)*(YEAR(J6:K1000)=2014))

    but now I need the first criteria to be a text specifically "DT*", and the second to be before november (<11)

    can you help?

  5. I have a workbook with multiple worksheets of inventory from various departments. I'm trying to create a summary page that sums the different categories of inventory from each worksheet tab. For example, how many desks do we have in total.

    My worksheets are set up like this:
    Desks. 26
    Chairs. 57
    Cabinets. 1

    But the info isn't in the same cells on each worksheet.

    Is this possible? Im p.yaong with countif but can't get it to work.

    1. Hi Dean,

      An immediate solution that comes to mind is using a combination of SUMIF functions like this:

      =SUMIF(Sheet2!A2:A7, "desks", Sheet2!B2:B7) + SUMIF(Sheet3!A6:A17, "desks", Sheet3!B6:B17)

      Where column A contains the categories of inventory and column B - the corresponding numbers. You can specify different ranges and different columns for each sheet.

      For more information about the SUMIF function with multiple criteria, please see this tutorial:
      https://www.ablebits.com/office-addins-blog/excel-sumifs-multiple-criteria/

  6. Nevermind! I found the solution elsewhere.

  7. I have a situation where the text that I want to count instances of is in various locations within the cells, e.g. A1 cell may contain 'Dog'; A2 cell may contain 'Cat, Dog', cell A3 may contain 'Bird, Cat, Dog'. I want to count all of the instances within the column that contains the word 'Dog'. It seems that no matter how I try to finesse this using COUNTIF and COUNTIFS with FIND and SEARCH etc. I can't seem to get this to work.

    Please help.

  8. I'm trying to create a spreadsheet to keep up with employee's absences, tardies, etc. for a year. Each incident is not counted after a year. So I have a cell on top that says today's date and used =today() so that when I open the file the date will fill in. I have the dates in the first column, the second is tardies, leave early and vacation. On top under today's date, I want it to show the total Tardies, for a year (from today minus one year).

    Today's Date '=today()

    Tardies ??? <---- This should be a total for the year using
    Leave Early ??? <---- same as above
    vacation ??? <---- same as above

    Date Tardies Leave Early Vacation
    11/01/13 1
    11/02/13 1
    11/03/13 1
    11/04/13 1
    11/05/13 1
    11/06/13 1

    For Example: the ???'s above should add from today (11/2/14) to 11/2/13 and give me a total of 2 so that when I open the spreadsheet on a certain day, that information will automatically update and show me how many tardies, leave earlies and vacation days they have for that given year.

  9. how would I write it sothat I could count a number if a condition is met EG
    A2=Knife
    B2=2
    A3=Spoon
    B3=4
    A4=Fork
    B4=3
    A5=Knife
    B6=7

    and I want b1 to count where A2:A5 = Knife but use the totals in B2:B6
    So it would count = 9

  10. Hi all,

    I Believe someone can help me here. what i want is from few different cell, i want to select certain letters or numbers. and want to to be able to link to one cell where it
    collect the selected letters and numbers from different cell and show as eg. cell 4 = (12345GB).

    eg. cell 1 = 0012
    eg. cell 2 = 4434
    eg. cell 3 = Good Buy

    i hope this is clear. its just so as i am inputting data on other cells and it generates like a ref if you like on the cell 4 as i instructed.

    please help?

  11. Hi,

    I want to count 1 column of data (contains £££) if another column contains a specific word.

    Could you help?

    Thanks

    1. Hi RC,

      I am not sure I understand your task correctly. Anyway, if you want to sum cell in column A if a corresponding cell in column B contains a given word, you can use the following SUMIF formula:

      =SUMIF(B:B,"word",A:A)

  12. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    25
    64
    54
    654
    546
    40

    so how can find highest number in excel sheet

    1. Hi Zaheer,

      You can use the MAX function for this, e.g:
      =MAX(A1:A20)

      Where A1 is the first and A20 is the last cell in the range.

  13. as example,,in the first sheet as below,,,
    A B D E F
    CODE FILLING STATION K.M AMOUNT ALAWNS
    5347 FALAJ AL-QABAIL F/S 15 16.74 1
    5294 FALAJ AL-QABAIL T 16 23.02 1
    5365 FALAJ AL-QABAIL N 17 23.02 1
    5727 SHINAS F/S 12 24.7 1.5
    5124 SOHAR BEACH F/S 25 24.7 1.5
    5530 SOHAR TREEF F/S 25 24.7 1.5
    5336 AL-WUQAIBA F/S 28 29.3 1.5
    5054 SOHAR SINAIYA F/S 29 29.3 2
    5299 SOHAR F/S 29 29.3 1.5
    5442 HUMAIRA F/S 30 29.3 1.5
    5211 AQAR F/S 45 38.51 2.5
    5438 AQAR TWIN FjS 47 41.86 2

    in the second sheet will be like as below,,,

    J k L M N
    CODE FILLING STATION K.M AMOUNT Allowances
    5727 ? ? ? ?
    5442 ? ? ? ?
    5294 ? ? ? ?

    My question is ,,if i type the number which is i column "A" in the secound sheet in the column "J" how can i make a formula to get the information from
    column "B" ,"C" , "D" , "E" in the secound sheet in the column "K" , "L"
    "M" ,"N" , ???or whatever columns in any sheet even at the same one,,

    i hope my question clear to you

    Thanks in Advance

  14. Hi

    I am currently struggling with this - I need a formula that works out the oldest date in A that does not have a processed date in Q.

    I have a formula that works out A =MIN(Audits!A7:A3026)but cannot figure out the COUNTIF for the second criteria, does anyone know if I am on the right track with a COUNTIF or am I just doing this wrong?

    Regards

  15. Thank you for the details shared.
    I have 4 digit numbers like 1234,2345,2334, etc. i want to know when 4 comes as 4th digit which number comes mostly in 3rd digit as well as in the 1st and 2nd.
    there are thousands of numbers looking forward for your reply. it would help me a lot

  16. hello

  17. -----A----------B------------C------------D-----------E
    --CODE------LOCATION-------KM-----------COST--------EXTRA
    --100-------SOHAR---------50------------25-----------2--

  18. hi,

    can you help please,,,
    i have five columns with differents informations and want to get all in another sheet by using only code, example:

    A B C D E
    CODE LOCATION KM COST EXTRA
    100 SOHAR 50 25 2

    the information in the cells never change,,,can i make a formula ,when typing a code then get the other information in another 4 cells

    thanks

  19. Greetings,
    Maybe I missed the answer but need help in applying a formula to only count dates that are within the last year. My data is pulled from SharePoint Lists then using another tab I am able to count how many items are done based on each section (currently have 5 different sections)
    The formula I am using is:

    COUNTIFS(Table1[Section],”Section”,Table1[Safety],””)

    I would like it to only count the dates in Safety that are within the last year when the sheet is refreshed.

    Any help will be greatly appreciated.

    1. After safety I have between the quotes in the formula.

  20. I need to calculate following Commissions on Sales how can i put in Formula

    <=20,000 = 1000 (Fixed)

    20,000 to 50,000 = 4%

    50000 to 100,000 = 3%

    100,000 to 200,000 = 2.5%

    And

    200,000 and Above =2%

    Please help me ...

  21. Hi,

    I came across to this forum and it looks nice.
    I need your help in excel that would assign the same number in multiple rows example below.

    I need to do this in 58,000 plus records and really want to somehow automate the process.

    Col1 Col2 Results
    Kit 1 Kit 1
    Kit 2 Kit 1
    Kit 3 Kit 1
    Len 4 Len 2
    Len 5 Len 2
    Len 6 Len 2
    Len 7 Len 2
    Daddy 8 Daddy 3
    Daddy 9 Daddy 3
    Daddy 10 Daddy 3
    Amy 11 Amy 4
    Amy 12 Amy 4
    Amy 13 Amy 4
    Stephanie 14 Stephanie 5
    Stephanie 15 Stephanie 5
    Stephanie 16 Stephanie 5
    Mommy 17 Mommy 6
    Mommy 18 Mommy 6
    Mommy 19 Mommy 6
    Mommy 20 Mommy 6

    1. Col1 Col2 Results
      Kit 1 Kit 1
      Kit 2 Kit 1
      Kit 3 Kit 1
      Len 4 Len 2
      Len 5 Len 2
      Len 6 Len 2
      Len 7 Len 2
      Daddy 8 Daddy 3
      Daddy 9 Daddy 3
      Daddy 10 Daddy 3
      Amy 11 Amy 4
      Amy 12 Amy 4
      Amy 13 Amy 4
      Stephanie 14 Stephanie 5
      Stephanie 15 Stephanie 5
      Stephanie 16 Stephanie 5
      Mommy 17 Mommy 6
      Mommy 18 Mommy 6
      Mommy 19 Mommy 6
      Mommy 20 Mommy 6

  22. hi,
    i have multiple mobile numbers where i want to check that how many time 1 Numbers coming but i am not able found however i have check with countifs but it not happening so please help me then how can check such type values in 10 digit mobile numbers

    Regards
    Bhajan lal Sharma

  23. Ok. Because question 4 passed in mass i need to track earned sick time. I want to set up the sheet that if a cell is 30 the next cell =1 if 60 =2 and so on. What formula should I use.

  24. Is there way count cells when the date change? Say for instance I have a list people and their birthdays. Column A includes the names and Column B includes the birthdays. Is it possible to count how many people have the same birthdays? I believe I can do it birthday individually but is there is there a function that will automatically count them. I am do something similar to that however I have over 75,000 records to check. Is there that well automatically give me total after each birthday is changed. Like, if the previous birthday is not equal to the next date, display total of the previous birthday and reset total. Please advise. Thanks in advance!

  25. Svetlana,

    Having some dificulties trying to figure out, how to count certain transactions that met 2 criterias City=Dallas and Type=SH.
    The table has multiple values and the following columns

    City
    Date
    Type
    Transaction

    I have been trying using Countifs, with no success.

    Thanks a lot for your support.

    Juan Pablo...

  26. Hello Svetlana,

    can you help please?

    I have a workbook referencing different tabs, on one sheet I have:

    Crew Manpower
    A 4
    A 4
    B 5
    C 3

    And on the other sheet I have:

    Crew Crew Member
    A John
    Steve
    Beto
    Frank

    B Ted
    Mike
    Chris
    Nate
    Terry

    In the cell that states "Manpower" I wan to count the number of crew members according to the "crew" letter. I've tried nested COUNTA, IF, AND COUNTIFS and i keep getting errors.

    what am i doing wrong?

    Thank you!

  27. Hi,

    Im trying to do a sum of a range whilst looking at the date completed, for example....

    Qty Date
    5 02-Oct-14
    100 02-Nov-14
    5 02-Oct-14
    5 02-Nov-14
    4 02-Nov-14
    54 02-Dec-14
    5 02-Dec-14
    6 02-Dec-14

    Is there a formula give me the sum of left column against the factor Oct for instance and should bring back the result 10.

    Thanks for your help
    Gavin

  28. Is there any way I can use a formula that will add up different amount of rows but in the same column? Example. In cell AG12, I need it to have the sum of AF8:AF12, however, then I need AG15 to have the sum of AF13:AF15

    1. The only solution I can suggest in this case is writing different formulas for those cells.

  29. Hi Svetlana,

    I have data in Col that A.
    I want to know no of lines between each pipe (|)

    Expected Result in B col for
    first pipe is 0
    Second Pipe is 6
    Third Pipe is 7

    Data
    |
    1
    ZGF1213420
    S ILIYAAZ
    S AZEES MIAH
    34-53-22
    29
    |
    2
    ZGF0316174
    U SUMALATA
    NARASHIMHA
    MURTHI
    53/1
    21
    |

    Kindly do the neeful.
    I have emailed the sheet to you emailid.

    1. Hi Khalid,

      You need a special macro for your task, sorry I cannot help with this.

  30. I skimmed the comments and didn't see my situation listed:
    I want to determine the number of unique entries in a column (D:D) that fall between a pair of dates (say a1 and a2) where the dates of the events are in a different column (J:J).
    I know I can count all of the entries in the date range using
    =COUNTIFS(!J:J, ""&A2)
    and I know I can count all of the unique entries in D:D using
    =SUMPRODUCT((D:D"")/COUNTIF(D:D,D:D&""))

    How do I put them together?

    1. That didn't post right:
      COUNTIFS(J:J, ""&A2)

      1. It's not posting correctly, but hopefully you can interpret what I mean.
        COUNTIFS(J:J, ""&A2)

        Thank you for any help.

        1. Hello!

          Regrettably, we don't know the way to fulfill your task using just one formula. You can either add a helper column or use a VBA macro.

          For example, you can enter one of the following formulas in cell K2 (if unique entries are checked by column D and date range):
          1 =IF(AND(J2>=$A$1,J2<=$A$2,COUNTIFS(D:D,D2,J:J,">="&$A$1,J:J,"<="&$A$2)=1),1,0)

          If you check for unique data only by column D:
          2 =IF(AND(J2>=$A$1,J2<=$A$2,COUNTIF(D:D,D2)=1),1,0)

          Just copy the formula to the other cells of the helper column and then sum the data in the column.

          1. Thank you for the quick and informative reply.

            1. Hi
              I want to use coutifs to select some criteria and count the number of unique numbers (or text) in a column.
              Is this possible?

              eg I have a list of product codes and each code as a different column for the colour, I want to count the number of product codes (ie some are in more than once)

              Cheers, Kate

  31. Is it possible to change the value of a cell so that is counted as two as opposed to one? I'm using COUNTIF to calculate the number of hours each employee is working in a schedule, but some cells equate to 2 hours and others equate to 3.

    1. Hi Abby,

      And how do you determine that a particular cell equates 2, or 3 or 1?

  32. In cells A1 to A30 I have 2 alphabets A&E and in the BCells have values .I need a formula to count the no. Of values of A& E in the Bcell. Pl help

    1. Hello Gespion,

      Try the following formulas:

      Sum values in column B corresponding to "A" in column A:
      =SUMIF(A1:A20,"a",B1:B30)

      Sum values in column B corresponding to "E" in column A:
      =SUMIF(A1:A20,"e",B1:B30)

  33. Hi,

    Your example 4: The formula show B and C cells but you highlighted B and D cells in the printscreen.

    Regards.

  34. Hi - how can I find the LATEST TIME for different products. Product can be repeated multiple times. example:

    Prod1 - 12:30
    Prod1 - 13:45
    Prod2 - 07:00
    Prod2 - 16:00
    Prod1 - 09:00

    Now it should report Prod1 as 13:45 and Prod2 as 16:00.

    Thanks for your help in advance.

  35. Hey Svetlana Cheusheva, I am trying to count values in a column, but I would like to leave out all the blanks and 0 values. Any help would be appreciated.

  36. Hi,

    I have a doubt in excel. I have row from a1 to d1 with numbers or string and c1 have no numbers or string.

    what i am looking is when any cell is blank then the formula would return the text otherwise sum of all number from a1 to d1.

    reply or solutions much appreciated

    thanks

    1. hi

      Can you explain with an example?

      If you come with an example that would be great

    2. I don't have too much experience but I think a simple if min=0 then text else sum shoulf=d be easy to make.

  37. Hi there,

    Here is the formula I am working with that almost produced the desired result:
    =COUNTIF('Entity SPORTS'!$A6:$A20,"'Entity SUMMARY'!A6")+COUNTIF('Entity SPORTS'!$C6:$C20,"m")

    I want to count ONLY IF the first part is true AND the second part is true. Should I be using a different type of formula?

    To provide some context: On one worksheet I have a list of clubs (column a - club name is repeated as many times as there are people in the club), the names of the people in the clubs (column b), and their gender (column c, listed as M or F). I want to summarize the number of males and females for each club on a separate worksheet so that column A states the club name, column b will have the number of M, and column C will have the number of F.

    Any help would be greatly appreciated!

  38. Hi Svetlana, I just sent you an email asking for your help with a formula. Thank you so much for all you do!

  39. Hi, Svetlana,

    Do you know if you can use countifs accross multiple worksheets? I'm tyring to count an occurance of a entry from a pick list, it occurs in the same column on each sheet but I can't find out how to reference multiple sheets?

    Any help would be greatly apprciated!

    1. Hi Brandy,

      Just add a sheet's name with the exclamation mark before the range, for example like this:
      =COUNTIFS(Sheet1!A:A,1, Sheet2!A:A,1)

      This formula counts how many 1's there are in column A in Sheet1 and Sheet2 in the same rows.

      1. Hello Svetlana,
        Iam impressed with your suggestions given above.
        below is the table for date & related days. I want count of total Saturdays. Means it should not consider repeated entries of same dates.
        My result should be 2.

        Can you help me
        3-Jan-15 Sat
        3-Jan-15 Sat
        10-Jan-15 Sat
        10-Jan-15 Sat

        Thanks in advance.

        1. Hello Tushar,

          If you want to count only unique Saturdays, then you need to add a helper column to your table.

          Please enter the following formula into the 2nd cell of the helper column:
          =IF(AND(COUNTIF($A$2:A2,A2)=1,WEEKDAY(A2,2)=6),1,0)

          Where A is the column with dates.

          Then just copy the formula down to the end. After that you need to sum this column, e.g. =sum(C:C)
          Where C is the helper column.

  40. Svetlana Cheusheva
    Hi,

    I'm trying to get a count of common digit like (1234-2345-2789-1289-2548 = 2 100% 4 50% 8 50% 3 20%

    Please help

  41. Hi Svetlana,

    Just mailed you my sheet can you help me with that please

  42. Just mailed you my sheet can you help me with that please

  43. Hi,

    I'm trying to get a count of dates that are due but on condition that they are listed as being follow up. My countif for follow up works fine {=countif(Q2:Q,"*up")}, and my countif for overdue dates works fine {="Follow up (due = "&countif(J2:J,"<="&today()&" )")}, but no matter what I do I can't manage to combine them. Any help would be much appreciated.

    Thanx.

    1. Turns out that the was a bracket in the wrong place:
      ="Follow up (due = "&countif(J2:J,"<="&today())&" )"
      works very nicely.

  44. Hello,
    Problem I cannot seem solve.
    Looking for a formula that counts occurrences of a value IF they occur after a certain date.
    This works fine with SUMIF e.g. =SUMIF($O$2:$IU$2;"<=" & TODAY();O26:IU26) Where the sum of numbers after a certain date are returned.

    DATASET looks like:
    DATES : 25/10|26/10|27/10|28/10|29/10...
    TASK A done by: A | B | A | A | C
    TASK B done by: B | A | B | C | A

    I want to know how many times A, B and C occur after TODAY...

    Thanks a lot for your much appreciated help!

    Floris

    1. Hello Floris,

      Please specify how many tasks and how many A/B/C/ for each task you have. Are the dates sorted in ascending order? Do you want to get the result on the same sheet or on a new one?
      Anyway, I believe the best solution for this task is to use a VBA macro.

  45. Hi Swetlana,
    Hope you doing well.
    I am having difficulty with formulas of multiple critearia.

    My formulas below is worked with me.
    =Countif(ACTL!B3:B50001;A$1;ACTL!$E$2:$E$50000;B$2;ACTL!$G$2:$G$50000;$B7)
    I want to add one more criteria which is date period.My Dates coloumn is starting from C1 till C1000.
    The target date is at B1(15oct2014)
    How can I continue to my formulas which will give me the total after 15Oct2014.
    If you can help me on it will be appreciate.

    Thanks & Regards.
    Utkan

    1. Hi Utkan,

      All ranges in COUNTIFS formulas should have the same number of rows and columns. Most likely, you need this formula:

      =COUNTIFS(ACTL!B3:B50001;A$1;ACTL!$E$2:$E$50000;B$2;ACTL!$G$2:$G$50000;$B7, ACTL!$C$2:$C$50000;$B$1)

  46. Hi,

    I have a data in 2 rows 1st row contains date, and in the 2nd row i have comment codes, i want the latest comment code and latest date in a separate cell in the same row.

    Example:

    1st Row: 1-oct, 2-oct, 3-oct, 4-oct, 5-oct, 6-oct, 7-oct,.....
    2nd Row: ASDF DSFA FGHJ WERT, SDFA .....

    I want the latest comment and date at the end of row for each row.

    I hope you understand the requirement...please help me.

    Prasad

    1. Hello,

      I am not sure I can follow you. If you can send your sample workbook to our support team at support@ablebits.com, we will try to help.

  47. Dear Mam ,
    I will appreciate to resolve my problem.
    i have different date in column which i required the count where dates is mentioned and rest blank not count .
    Please help me

    Center Revised Date 2nd PM Plan Date 3rd PM Plan Date Total Count

    Bannu-1 1-Oct-14 1-Oct-14 Blank ?(Answers should be 2)

    1. Hello Muhammad,

      You can use this formula to count all non-blank cells:
      =COUNTIF(B2:F2,"*")

      To count only dates and numbers greater than 0, please use the following array formula (you have to press Ctrl + Shift + Enter to complete it):

      {=SUM(--NOT(ISERROR(DATEVALUE(TEXT(A2:F2,"mm/dd/yyy")))))}

      Where A2:F2 is the range you want to count.

  48. Hi,
    Is there a way to have a total price adjusted based on the day they typed a quantity into a cell? Lets say price goes up on oct 24 for apples, from $10 to $15. Is there a way to have it calculate the order of 2 apples on Oct 23 (before the 24th), but also calculate the total if they order the apples on the 25th (after the 24th)? If they didn't type in the quantity till after the advanced priced date. This has to be real time.

    Thanks, Ryan

  49. Hi,

    I am counting up unique string values in a range of cells in a column. Tow of the values are "Uses Look Up" and "Value in table". To attempt to get a sum of the counts of the 2, I set up the COUNTIFS functions as follows:

    =COUNTIFS(F1:F128,"=Uses Look Up",F1:F128,"=Value in table")

    The value retuned is 0, however, when I count them separately the count is 75. Why did the COUNTIFS function return 0?

    Thanks, Carlo

  50. Hello,

    I have an excel file with 2 worksheets: the first worksheet contains 10 columns and 10 rows with random values (A, B, C, D, E).

    I need a formula in the second worksheet to count the number of times that value "B" appears after value "A" in the first worksheet.

    It's really important and urgent, if you can answer this you would save me a big headache.

    Thank you

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