Skip to content
ArumSoft Learning
KO

    The 20 Most-Used Excel Functions · Tutorial 7 of 20

    How to Use COUNTIF and COUNTIFS in Excel

    Count the cells that meet a condition with COUNTIF, or several conditions at once with COUNTIFS, using operators, cell references and wildcards.

    Level
    Intermediate
    Time
    14 min read
    Updated:
    Applies to:
    Excel for Microsoft 365, Excel 2021, Excel 2019, Excel for the web
    Ten ratings. E2 counts the ratings of 4 or more, and E3 turns that count into a share of all ratings.
    Example: Ten ratings. E2 counts the ratings of 4 or more, and E3 turns that count into a share of all ratings.

    What you'll learn

    • Count the cells that match one condition with COUNTIF
    • Count the rows that match several conditions with COUNTIFS
    • Write criteria with operators, cell references and wildcards
    • Avoid the criteria mistakes that give a wrong count

    Function Playground

    Try these functions in a live sheet

    Type formulas in an Excel-style grid and watch each step of the calculation. Free, no sign-up.

    COUNT tells you how many cells hold numbers. COUNTIF tells you how many cells meet a condition: how many orders are paid, how many scores are 50 or more, how many entries start with "Laptop". COUNTIFS does the same with several conditions at once. Both recount by themselves when the data changes.

    The syntax

    =COUNTIF(range, criteria)
    • range is the cells to check, for example the Status column.
    • criteria is the condition: a value ("Paid", 1000), a comparison in quotes (">=1000") or a cell reference.
    Reading a COUNTIF formula
    =COUNTIF(D2:D9,"Paid")
    1. D2:D9range: the cells to check, here the Status column
    2. "Paid"criteria: the condition a cell must meet to be counted
    =COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...)
    • criteria_range1, criteria1 are the first range to check and its condition.
    • criteria_range2, criteria2, … are optional extra pairs, up to 127. A row is counted only when it meets every condition.
    Reading a COUNTIFS formula
    =COUNTIFS(B2:B9,"East",D2:D9,"Paid")
    1. B2:B9criteria_range1: the first column to check
    2. "East"criteria1: the condition for B2:B9
    3. D2:D9criteria_range2: the second column to check
    4. "Paid"criteria2: the condition for D2:D9, on the same row

    Count the paid orders

    The sheet below lists eight orders. The goal is the number of paid orders in G3.

    1. Click the cell for the result

      Click G3, next to the label "Paid orders".

      ABCDEFG
      1ProductRegionAmountStatusSummaryCount
      2LaptopEast1,200PaidMinimum amount1,000
      3MonitorWest300PendingPaid orders
      4Laptop standEast45PaidMinimum or more
      5LaptopNorth1,100PaidEast, paid
      6KeyboardWest80PendingPending, minimum or more
      7LaptopEast1,300Pending
      8MonitorNorth280Paid
      9Laptop standWest50Paid
      Eight orders with a product, region, amount and status. The count of paid orders goes in G3.
    2. Type =COUNTIF( and select the range to check

      Type =COUNTIF( and drag over D2:D9, the Status column. Type a comma.

    3. Type the condition and press Enter

      Type "Paid" and press Enter. Text in a condition always goes in double quotes. Capitals don't matter: "paid" counts Paid too.

      =COUNTIF(D2:D9,"Paid")
      ABCDEFG
      1ProductRegionAmountStatusSummaryCount
      2LaptopEast1,200PaidMinimum amount1,000
      3MonitorWest300PendingPaid orders5
      4Laptop standEast45PaidMinimum or more
      5LaptopNorth1,100PaidEast, paid
      6KeyboardWest80PendingPending, minimum or more
      7LaptopEast1,300Pending
      8MonitorNorth280Paid
      9Laptop standWest50Paid
      COUNTIF counts the five cells in D2:D9 that say Paid (green) and returns 5.

    Unlike SUMIF, COUNTIF has no third argument. It doesn't add anything; it only counts the cells in range that match.

    Use a comparison or a cell in the condition

    To compare numbers, put the operator and the number together in quotes:

    OperatorMeaningExample
    = (or nothing)equal to"Paid" or 1000
    <>not equal to"<>Paid"
    > / >=greater than / at least">=1000"
    < / <=less than / at most"<100"

    This counts the orders of 1,000 or more and returns 3 (1,200, 1,100 and 1,300):

    =COUNTIF(C2:C9,">=1000")

    With ">1000" instead, an order of exactly 1,000 would no longer count. Check whether your limit itself should be included.

    A condition that lives in a cell is easier to change. On its own, the cell needs no quotes: =COUNTIF(B2:B9,H2) counts whatever region is typed in H2. To combine an operator with a cell, put the operator in quotes and join it to the cell with &. With 1000 in G2, this also returns 3, and the count changes when you type a new minimum in G2:

    =COUNTIF(C2:C9,">="&G2)

    Two more conditions are worth knowing: "<>" counts cells that aren't empty, and "" counts cells that are.

    Count with several conditions: COUNTIFS

    COUNTIFS takes the conditions in pairs: a range, then its condition. This counts the paid orders from the East region and returns 2:

    =COUNTIFS(B2:B9,"East",D2:D9,"Paid")
    ABCDEFG
    1ProductRegionAmountStatusSummaryCount
    2LaptopEast1,200PaidMinimum amount1,000
    3MonitorWest300PendingPaid orders
    4Laptop standEast45PaidMinimum or more
    5LaptopNorth1,100PaidEast, paid2
    6KeyboardWest80PendingPending, minimum or more
    7LaptopEast1,300Pending
    8MonitorNorth280Paid
    9Laptop standWest50Paid
    Rows 2 and 4 are East and Paid, so they count (green). Row 7 is East but Pending, so it doesn't (amber).

    You can check the same column twice, which is how you count values between two limits. This counts amounts of at least 100 but under 1,000 and returns 2 (300 and 280):

    =COUNTIFS(C2:C9,">=100",C2:C9,"<1000")

    COUNTIFS has no "or": every condition must be true in the same row. To count East or West orders, add two COUNTIF results together. This returns 6:

    =COUNTIF(B2:B9,"East")+COUNTIF(B2:B9,"West")

    Count partial matches with wildcards

    In text conditions, * stands for any number of characters (including none) and ? for exactly one. This counts every product that starts with "Laptop" and returns 5: three Laptops and two Laptop stands.

    =COUNTIF(A2:A9,"Laptop*")

    Without the asterisk, "Laptop" matches only the exact text and returns 3. "*stand" matches anything that ends in "stand" (2), and "?????" matches any five-character entry. To count a real asterisk or question mark, put a tilde before it: "~*".

    You can join a wildcard to a cell too. If H2 holds a word, =COUNTIF(A2:A9,"*"&H2&"*") counts the products that contain it anywhere.

    COUNTIF and the other counting functions

    Excel has several counting functions. They differ in what they count:

    FunctionCountsExample on the order sheet
    COUNTcells that hold numbers=COUNT(C2:C9) returns 8
    COUNTAcells that aren't empty=COUNTA(D2:D9) returns 8
    COUNTBLANKempty cells=COUNTBLANK(D2:D9) returns 0
    COUNTIFcells that meet one condition=COUNTIF(D2:D9,"Paid") returns 5
    COUNTIFSrows that meet every condition=COUNTIFS(B2:B9,"East",D2:D9,"Paid") returns 2

    Real-world scenarios

    School

    Absences in an attendance register

    An attendance register has one row per student and one column per day, with P for present and A for absent. COUNTIF works across a row just as it does down a column.

    ABCDEFG
    1StudentMonTueWedThuFriAbsences
    2MinaPPAPP1
    3LeoPAAPP2
    4SamPPPPP0
    5YunaAPPPA2
    6Perfect attendance1
    A week of attendance. Column G counts each student's A entries, and G6 counts the students with no absences.
    =COUNTIF(B2:F2,"A")

    Mina was absent on Wednesday, so G2 returns 1. Fill the formula down to G5 and each row counts its own days: Leo 2, Sam 0, Yuna 2. In G6, =COUNTIF(G2:G5,0) counts the zeros among those results and returns 1: Sam is the only student with perfect attendance.

    Inventory

    Items to reorder

    An office supply list shows how many of each item are left. Anything below the reorder level in F3 needs ordering, and F2 holds the category to check.

    ABCDEF
    1ItemCategoryIn stockReorder checkValue
    2Copy paperPaper12CategoryPaper
    3EnvelopesPaper40Reorder below20
    4Sticky notesPaper8Category to reorder2
    5TonerPrinter3All to reorder5
    6InkPrinter15
    7PensDesk60
    8StaplesDesk9
    9NotebooksPaper25
    Eight supplies. F4 counts the Paper items with fewer than 20 left; F5 counts every item below 20.
    =COUNTIFS(B2:B9,F2,C2:C9,"<"&F3)

    It returns 2. Of the four Paper items, Copy paper (12) and Sticky notes (8) are below 20, while Envelopes (40) and Notebooks (25) aren't. In F5, =COUNTIF(C2:C9,"<"&F3) drops the category and returns 5: Copy paper, Sticky notes, Toner, Ink and Staples. Change the level in F3 and both counts update.

    Events

    Duplicate sign-ups

    People sign up by email for a morning or an afternoon workshop, and some sign up twice. The same email in two different sessions is fine; the same email twice in the same session is a duplicate.

    ABC
    1EmailSessionCheck
    2ana@example.comMorning
    3ben@example.comMorningDuplicate
    4ana@example.comAfternoonDuplicate
    5chloe@example.comMorning
    6ben@example.comMorningDuplicate
    7dev@example.comAfternoon
    8ana@example.comAfternoonDuplicate
    Seven sign-ups, with the formula filled down column C. C3 checks Ben's Morning sign-up, which appears twice.

    Type this in C2 and fill it down to C8:

    =IF(COUNTIFS($A$2:$A$8,A2,$B$2:$B$8,B2)>1,"Duplicate","")

    For each row, COUNTIFS counts the rows with the same email and the same session. The $ signs keep the whole list fixed while A2 and B2 move down a row at a time. When the count is more than 1, IF shows Duplicate. Ben's two Morning sign-ups (rows 3 and 6) and Ana's two Afternoon sign-ups (rows 4 and 8) are flagged. Ana's Morning sign-up in row 2 isn't, because she's in that session only once. Both copies of a duplicate are flagged, so you can decide which one to delete.

    Customers

    Share of satisfied customers

    Ten customers rated a service from 1 to 5. Count the 4s and 5s, then divide by the number of ratings to get a percentage.

    ABCDE
    1ResponseRatingSummaryValue
    215Rated 4 or 57
    324Share satisfied70%
    433
    545
    652
    764
    875
    981
    1094
    11105
    Ten ratings. E2 counts the ratings of 4 or more, and E3 turns that count into a share of all ratings.
    =COUNTIF(B2:B11,">=4")/COUNT(B2:B11)

    Seven of the ten ratings are 4 or 5, so the formula returns 0.7, which shows as 70% once the cell is formatted as a percentage. COUNT counts only cells with numbers, so if a customer skips the question and the cell stays empty, the share isn't pulled down.

    Mistakes that give the wrong count

    • A cell reference inside the quotes. ">=G2" compares with the text "G2", so nothing matches and the result is 0. Write ">="&G2.
    • Ranges of different sizes. In COUNTIFS, every criteria range must have the same number of rows and columns, or the result is #VALUE!. Use the same rows everywhere, like B2:B9 and D2:D9.
    • Labels that almost match. "Paid " with a trailing space isn't "Paid", so that row is skipped without warning. Clean the data with TRIM, or use a drop-down list so the labels are always typed the same way.
    • Expecting "or" from COUNTIFS. =COUNTIFS(B2:B9,"East",B2:B9,"West") returns 0, because no single cell can be both. Add two COUNTIF results instead.
    • Counting a header or total. If the range includes the header row or a total row, those cells are checked too. Keep the range to the data rows.

    Practice

    Practice

    Build an order summary

    Use the sheet below. Click a highlighted cell, type a formula in the bar above the sheet and press Enter. Afterwards, try it in Excel itself:

    1. List ten tasks from your week with a category (Work, Home, Study…) and a status (Done or Open).
    2. Under the list, count the Done tasks with COUNTIF.
    3. Type a category in a cell and use COUNTIFS to count the open tasks in that category, using the cell as the condition.

    Try it0 of 4 done

    1. In G3, count the orders whose status is Paid.
    2. In G4, count the orders of at least the minimum amount in G2.
    3. In G5, use COUNTIFS to count the paid orders from the East region.
    4. In G6, count the pending orders of at least the minimum amount in G2.

    Click a dashed cell, type a formula in the bar and press Enter.

    ABCDEFG
    1ProductRegionAmountStatusSummaryCount
    2LaptopEast1,200PaidMinimum amount1,000
    3MonitorWest300PendingPaid orders
    4Laptop standEast45PaidMinimum or more
    5LaptopNorth1,100PaidEast, paid
    6KeyboardWest80PendingPending, minimum or more
    7LaptopEast1,300Pending
    8MonitorNorth280Paid
    9Laptop standWest50Paid

    Related

    Was this guide helpful? Spot a mistake? Send feedback · admin@arumsoft.com