To count cells that match a condition in Excel, use COUNTIF for one condition and COUNTIFS for two or more. Click an empty cell and type =COUNTIF(D2:D11,"Open") to count every cell in D2:D11 that says Open, or =COUNTIFS(C2:C11,"High",D2:D11,"Open") to count only the rows that are both High priority and Open. Each condition is written as a pair: the cells to check, then the rule they must meet.
Below you’ll find both functions worked through on one small sample sheet, followed by every common type of criteria (text, numbers, dates, wildcards, “not equal to”, blank and non-blank cells), OR conditions, case-sensitive counting, and what to do when the count comes back as 0, #VALUE! or a number that looks wrong.
What you need and which versions this covers
Microsoft’s function reference lists COUNTIF and COUNTIFS for Excel for Microsoft 365 on Windows and Mac, Excel 2024, Excel 2021, Excel 2019, Excel 2016 and Excel for the web, and the formulas in this guide work the same way in all of them. A few examples use newer dynamic array functions such as UNIQUE; those are marked, because they need Microsoft 365, Excel 2021 or later, or Excel for the web.
Before you start, it helps to know three terms:
- A range is a block of cells, written as the first and last cell with a colon between them, such as
D2:D11. - A criterion (plural criteria) is the rule a cell has to meet to be counted, such as
"Open",">3"or a reference to a cell that holds the value. - An argument is one of the values you put inside a function’s parentheses, separated by commas.
If your Excel uses a comma as the decimal separator (common in many European regional settings), type a semicolon between arguments instead of a comma, for example =COUNTIF(D2:D11;"Open").
COUNTIF vs. COUNTIFS: which one to use
Both functions return a number: how many cells or rows passed a test. They don’t add up values (that’s SUMIF and SUMIFS) and they don’t return the matching items themselves (that’s FILTER). Here’s how they differ:
| COUNTIF | COUNTIFS | |
|---|---|---|
| Syntax | =COUNTIF(range, criteria) |
=COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2], ...) |
| Conditions | Exactly one | One or more, up to 127 range and criteria pairs |
| How conditions combine | Not applicable | AND: a row counts only when it meets every condition |
| Range sizes | One range | Every range must have the same number of rows and columns as the first one |
| Wildcards (* and ?) | Yes | Yes |
| Case-sensitive | No | No |
A simple rule: if your question has the word “and” in it (“how many tickets are High priority and still Open?”), use COUNTIFS. If it has one condition, either function works; COUNTIF is shorter to type. COUNTIFS with a single pair, such as =COUNTIFS(D2:D11,"Open"), gives exactly the same answer as COUNTIF, so some people use COUNTIFS everywhere so they can add conditions later without rewriting the formula.

Sample data for the examples
Every formula in this guide uses the small support-ticket log below. To follow along, type it into a blank sheet starting in cell A1. Notice that the Status cell in row 11 is left empty on purpose so you can try the blank-cell examples.
| Row | A: Opened | B: Agent | C: Priority | D: Status | E: Hours |
|---|---|---|---|---|---|
| 2 | 9/1/2026 | Jordan | High | Closed | 3 |
| 3 | 9/2/2026 | Priya | Low | Open | 1 |
| 4 | 9/3/2026 | Jordan | Medium | Open | 2 |
| 5 | 9/8/2026 | Sam | High | Closed | 5 |
| 6 | 9/9/2026 | Priya | High | Open | 4 |
| 7 | 9/15/2026 | Jordan | Low | Closed | 1 |
| 8 | 9/16/2026 | Sam | Medium | Pending | 2 |
| 9 | 9/22/2026 | Priya | Medium | Closed | 3 |
| 10 | 9/23/2026 | Jordan | High | Pending | 6 |
| 11 | 9/29/2026 | Sam | Low | (empty) | 1 |
How to use COUNTIF
This example counts how many tickets have the status Open.
Step 1: Click the cell where you want the count
Pick an empty cell outside your data, such as G2. You may want to type a label like “Open tickets” in the cell to its left or above it so you remember what the number means.
Step 2: Type the function name and the range to check
Type =COUNTIF( and then drag across D2:D11, or type D2:D11. As you type, Excel shows a small tooltip under the cell with the argument names, and the one you’re on appears in bold. Type a comma after the range.
Step 3: Type the criteria
Type "Open" with the double quotation marks, then a closing parenthesis. Text and anything that includes an operator such as > or <> must be inside quotes. A plain number, such as 3, or a cell reference, such as G1, doesn’t need them. Your formula now reads =COUNTIF(D2:D11,"Open").
Step 4: Press Enter and check the result
Press Enter. The cell shows 3, because rows 3, 4 and 6 are Open. Click the cell again and the formula appears in the formula bar above the column letters, where you can edit it. A quick way to sanity-check any count is to apply a filter to the column (Data > Filter), pick the same value, and look at the record count in the status bar at the bottom of the window.

How to use COUNTIFS
This example counts tickets that are High priority and still Open.
Step 1: Click an empty cell
Select a cell such as G3 for the result.
Step 2: Enter the first range and its rule
Type =COUNTIFS(C2:C11,"High",. This is the first pair: Excel will look down the Priority column for cells that say High.
Step 3: Enter the second range and its rule
Type D2:D11,"Open") to add the second pair. The complete formula is =COUNTIFS(C2:C11,"High",D2:D11,"Open"). Make sure the second range covers the same rows as the first (2 through 11 here); if it doesn’t, Excel returns #VALUE!.
Step 4: Press Enter
The result is 1. Four tickets are High priority and three are Open, but only row 6 is both. COUNTIFS checks the first cell of every range together, then the second cell of every range, and so on, and counts a row only when all of its cells pass.
Step 5: Add more conditions if you need them
Keep adding pairs separated by commas. For example, =COUNTIFS(B2:B11,"Jordan",C2:C11,"High",D2:D11,"<>Closed") counts Jordan’s High-priority tickets that aren’t closed yet. The answer is 1 (row 10). Microsoft allows up to 127 pairs in one COUNTIFS formula.
Build the formula with Insert Function
If you’d rather fill in labeled boxes than remember the argument order, use the Insert Function tool.
Step 1: Open Insert Function
Click the result cell, then go to Formulas > Insert Function, or select the fx button to the left of the formula bar.
Step 2: Find the function
Type COUNTIFS in the search box, select Go, choose COUNTIFS in the list and select OK. In Excel for Mac and Excel for the web, the same boxes may appear in a side pane instead of a separate window.
Step 3: Fill in each pair
Click in Criteria_range1 and drag over C2:C11, then type High in Criteria1. Excel adds the quotation marks for you. As soon as you fill one pair, a new empty pair appears below it. Fill Criteria_range2 with D2:D11 and Criteria2 with Open. The preview near the bottom shows the result before you commit.
Step 4: Select OK
Excel writes the formula into the cell. You can reopen the window later by clicking the cell and selecting fx again.

Criteria cheat sheet
The criteria argument is where most of the power, and most of the mistakes, live. These patterns work the same way in COUNTIF and in each criteria box of COUNTIFS. Results use the sample data.
| What you want to count | Formula | Result |
|---|---|---|
| Cells equal to a word | =COUNTIF(B2:B11,"Jordan") |
4 |
| Cells equal to the value in another cell (G1 holds Priya) | =COUNTIF(B2:B11,G1) |
3 |
| Cells equal to a number | =COUNTIF(E2:E11,3) |
2 |
| Numbers greater than 3 | =COUNTIF(E2:E11,">3") |
3 |
| Numbers 3 or more | =COUNTIF(E2:E11,">=3") |
5 |
| Numbers less than 2 | =COUNTIF(E2:E11,"<2") |
3 |
| Not equal to a value | =COUNTIF(D2:D11,"<>Closed") |
6 |
| Greater than the number in a cell (G1 holds 3) | =COUNTIF(E2:E11,">"&G1) |
3 |
| Text that starts with J | =COUNTIF(B2:B11,"J*") |
4 |
| Text that contains “ium” anywhere | =COUNTIF(C2:C11,"*ium*") |
3 |
| Text exactly four characters long | =COUNTIF(D2:D11,"????") |
3 |
| Any text at all | =COUNTIF(D2:D11,"*") |
9 |
| Above the column’s average | =COUNTIF(E2:E11,">"&AVERAGE(E2:E11)) |
5 |
A few rules explain everything in that table:
- Operators go inside quotes. The comparison operators are = (equal), > (greater than), < (less than), >= (greater than or equal to), <= (less than or equal to) and <> (not equal to). Write them as part of a text string, such as
">=3". - Join an operator to a cell or formula with &. The ampersand glues pieces of text together, so
">"&G1becomes “>3” when G1 holds 3. Writing">G1"instead makes Excel look for cells greater than the literal text “G1”, which usually returns 0. - The asterisk (*) matches any number of characters, including none.
"*ium*"finds Medium;"J*"finds anything starting with J. - The question mark (?) matches exactly one character.
"????"finds Open but not Closed or Pending. - To find a real asterisk or question mark, put a tilde (~) in front of it.
=COUNTIF(A2:A50,"*~?")counts cells that end with a question mark. - Wildcards only work on text.
"3*"won’t match the number 30. Use a comparison such as">=30"for numbers.
“Not equal to” has one surprise: "<>Closed" returns 6, not 5, because the empty Status cell in row 11 also isn’t “Closed”. If you only want filled-in cells that aren’t Closed, use COUNTIFS with two pairs on the same range: =COUNTIFS(D2:D11,"<>Closed",D2:D11,"<>") returns 5.
Count by date or date range
Excel stores dates as serial numbers, so you count them with the same comparison operators you use for numbers. Give COUNTIF a real date, not text that only looks like one.
Count dates on or after a date
=COUNTIF(A2:A11,">="&DATE(2026,9,15)) counts tickets opened on or after September 15, 2026. The result is 5. Using DATE(year, month, day) avoids confusion between US month/day order and other regional formats. Typing ">=9/15/2026" also works on a US-English system.
Count dates between two dates
Use COUNTIFS with the same range twice, once for the start and once for the end: =COUNTIFS(A2:A11,">="&DATE(2026,9,1),A2:A11,"<="&DATE(2026,9,15)) returns 6 (September 1 through 15, including both days).
Use start and end dates stored in cells
Put the start date in G1 and the end date in H1, then use =COUNTIFS(A2:A11,">="&G1,A2:A11,"<="&H1). Change either date and the count updates. This is the easiest way to build a small report that someone else can reuse.
Count relative to today
The TODAY function returns the current date, so =COUNTIF(A2:A11,"<"&TODAY()-7) counts tickets opened more than a week ago. The result changes every day, which is usually what you want for an aging report.
Watch out for dates that include times
If your column holds date and time values (for example, from an export), a ticket opened at 2:00 PM on September 15 is later than 9/15/2026 at midnight. An end date of "<="&DATE(2026,9,15) would miss it. Use "<"&DATE(2026,9,16) as the end condition instead so the whole last day is included.
Count blank and non-blank cells
Two short criteria handle empty cells:
=COUNTIF(D2:D11,"")counts blank cells. With the sample data, the result is 1 (row 11).=COUNTIF(D2:D11,"<>")counts cells that aren’t empty. The result is 9.
Excel also has dedicated functions: COUNTBLANK counts empty cells and COUNTA counts non-empty cells. Microsoft notes that COUNTBLANK also counts cells with formulas that return “” (empty text), and that it doesn’t count cells containing 0. That matters if your sheet uses formulas like =IF(E2>5,"Late",""): those cells look empty but contain a formula, so COUNTA and the "<>" criteria can count them as filled while COUNTBLANK counts them as blank. If your numbers don’t agree, check whether the “empty” cells actually contain a formula by clicking one and looking at the formula bar.
The blank tests are most useful inside COUNTIFS. For example, =COUNTIFS(B2:B11,"Sam",D2:D11,"") counts Sam’s tickets that don’t have a status yet (1).
Count with OR conditions
COUNTIFS always joins its conditions with AND. To count rows that match one value or another, you have three options.
Add two COUNTIF results
=COUNTIF(D2:D11,"Open")+COUNTIF(D2:D11,"Pending") counts tickets that are Open or Pending. The result is 5. This is the easiest version to read and works in every Excel version.
Use an array constant inside SUM
For a longer list of values, put them in curly braces: =SUM(COUNTIF(D2:D11,{"Open","Pending"})). COUNTIF returns one count for each item in the braces, and SUM adds them. You can combine this with other conditions in COUNTIFS, such as =SUM(COUNTIFS(B2:B11,"Jordan",D2:D11,{"Open","Pending"})), which returns 2. If the values are in cells (say G1:G2), =SUM(COUNTIF(D2:D11,G1:G2)) works the same way in Microsoft 365; in Excel 2019 and earlier, press Ctrl + Shift + Enter instead of Enter so it’s treated as an array formula.
Avoid double counting across different columns
Adding counts only works when one row can’t match both conditions. Two statuses in the same column can never overlap, but “High priority OR Open” can: row 6 is both. =COUNTIF(C2:C11,"High")+COUNTIF(D2:D11,"Open") returns 7, which counts row 6 twice. Subtract the overlap with COUNTIFS to get the right answer: =COUNTIF(C2:C11,"High")+COUNTIF(D2:D11,"Open")-COUNTIFS(C2:C11,"High",D2:D11,"Open") returns 6.
For more complicated mixes of AND and OR across several columns, SUMPRODUCT is often clearer: =SUMPRODUCT(--(((C2:C11="High")+(D2:D11="Open"))>0)) also returns 6. Each test produces a list of TRUE and FALSE values, the plus sign means OR, >0 turns “matched at least once” into TRUE, and the double minus turns TRUE and FALSE into 1 and 0 for SUMPRODUCT to add.
Case-sensitive counts
Microsoft’s documentation states that COUNTIF criteria aren’t case sensitive: “apples” and “APPLES” match the same cells, and the same is true for COUNTIFS. If capitalization matters (for example, product codes where “ab-1” and “AB-1” are different items), use the EXACT function, which does compare case: =SUMPRODUCT(--EXACT(B2:B11,"Jordan")) returns 4, while =SUMPRODUCT(--EXACT(B2:B11,"jordan")) returns 0. EXACT doesn’t support wildcards.
Practical examples
A count for every agent
Type the agent names in G2:G4 (Jordan, Priya, Sam). In H2, enter =COUNTIF($B$2:$B$11,G2) and fill it down to H4. The dollar signs make the range an absolute reference, meaning it stays fixed while the criteria cell changes row by row. The results are 4, 3 and 3. In Microsoft 365 you can skip the typing entirely: =UNIQUE(B2:B11) in G2 lists the agents, and =COUNTIF(B2:B11,G2#) in H2 returns all three counts at once (the # refers to the whole list that UNIQUE spilled).
An agent-by-status grid
Put agent names down column G (G2:G4) and statuses across row 1 (H1 Open, I1 Closed, J1 Pending). In H2 enter =COUNTIFS($B$2:$B$11,$G2,$D$2:$D$11,H$1), then copy it across and down. The mixed references ($G2 locks the column, H$1 locks the row) let one formula fill the whole grid. You should see Jordan 1, 2, 1; Priya 2, 1, 0; Sam 0, 1, 1. Each column total matches the single COUNTIF results above (3 Open, 4 Closed, 2 Pending), which is a handy way to check your work.

Count numbers between two values
=COUNTIFS(E2:E11,">=2",E2:E11,"<=4") counts tickets that took between 2 and 4 hours, inclusive. The result is 5. Drop the equals signs to exclude the end values.
Flag duplicates
To check whether a value appears more than once, compare each cell with the whole column. In F2 enter =COUNTIF($B$2:$B$11,B2)>1 and fill down; TRUE means the agent name appears in another row too. To see how many times each value appears, drop the >1. The same formula works as a conditional formatting rule (Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format) if you’d rather highlight duplicates in color.
Count distinct values
To count how many different agents appear, use =COUNTA(UNIQUE(B2:B11)) in Microsoft 365, Excel 2021 or later, or Excel for the web. It returns 3. In older versions, =SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11)) gives the same answer, as long as the range has no blank cells (a blank makes the formula divide by zero).
Use an Excel table so new rows are counted
If you add tickets every week, convert the data to a table with Insert > Table (or Ctrl + T). Formulas that point at table columns, such as =COUNTIF(Table1[Status],"Open"), grow automatically when you add rows, so you never have to edit the range.
Count from another sheet
Put the sheet name and an exclamation point before the range: =COUNTIF(Tickets!D2:D11,"Open"). If the sheet name has spaces, wrap it in single quotes, like ='Ticket Log'!D2:D11. Clicking over to the other sheet and selecting the cells while you type the formula fills this in for you.
Fix a wrong count, 0 or #VALUE!
The result is 0 but you can see matching cells
- Extra spaces. “Open ” with a trailing space doesn’t equal “Open”. Microsoft recommends checking for leading or trailing spaces, inconsistent straight and curly quotation marks, and nonprinting characters, and cleaning them with TRIM or CLEAN. A quick test is
=LEN(D3): if it shows 5 for “Open”, there’s a hidden character. - Criteria missing quotes.
=COUNTIF(D2:D11,Open)without quotes makes Excel look for a named range called Open. Text criteria need quotes. - A cell reference typed inside the quotes.
">G1"looks for the letters G1. Use">"&G1. - Dates stored as text. Dates pasted from another system may be text that only looks like a date, often left-aligned in the cell. Date comparisons skip them. Convert them with Data > Text to Columns (select Finish), or with the DATEVALUE function.
- Wrong column. Click the formula and check the colored outlines Excel draws around each range; it’s easy to point at the column next to the one you meant.
The result is #VALUE!
- COUNTIFS ranges are different sizes. Each range must have the same number of rows and columns as the first one.
=COUNTIFS(C2:C11,"High",D2:D10,"Open")fails because the second range stops one row early. - The formula refers to a closed workbook. Microsoft notes that COUNTIF returns #VALUE! when it refers to cells in another workbook that is closed. Open the other workbook and the result reappears.
The count is higher or lower than expected
- A wildcard matches more than you meant.
=COUNTIF(D2:D11,"*pen*")looks like it counts Open tickets, but it returns 5 because “Pending” also contains “pen”. Use the exact word when you can, or test the pattern with a filter. - OR counts overlap. When you add counts from different columns, subtract the rows that match both (see the OR section above).
- The text you match is longer than 255 characters. Microsoft notes that COUNTIF returns incorrect results for strings longer than 255 characters. Split the criteria and join the parts with &, for example
"first part"&"second part". - “Not equal” includes blanks. Add a
"<>"condition if empty cells shouldn’t count. - Long ID numbers. Excel keeps only 15 significant digits in a number, and COUNTIF treats text that looks like a number as a number, so long IDs stored as text that share their first 15 digits can match each other. For those, compare as text with
=SUMPRODUCT(--(A2:A100=G1))instead of COUNTIF. - Calculation is set to manual. If counts don’t change when you edit data, go to Formulas > Calculation Options and choose Automatic.
Other messages
#NAME? means Excel doesn’t recognize something in the formula, usually a misspelled function name (COUNTIFS, not COUNTIFFS) or text criteria without quotes. If the cell shows the formula itself instead of a result, the cell was formatted as Text before you typed; change the format to General with Home > Number Format, then click into the formula and press Enter again.
COUNTIF and COUNTIFS can’t count cells by fill color or font color. Microsoft points to a VBA user-defined function for that; a simpler option for a one-time count is to filter by color (Data > Filter, then Filter by Color) and read the count in the status bar.
Frequently Asked Questions
What is the difference between COUNTIF and COUNTIFS?
COUNTIF counts cells that meet one condition in one range. COUNTIFS counts rows that meet every one of several conditions, each with its own range, such as Priority equals High and Status equals Open.
How do I count cells that contain specific text anywhere in the cell?
Wrap the text in asterisks: =COUNTIF(A2:A100,"*refund*") counts every cell with “refund” anywhere in it, in any capitalization.
Can COUNTIFS use OR logic?
Not directly; its conditions always combine with AND. Add separate COUNTIF or COUNTIFS results together, or use =SUM(COUNTIFS(range,{"A","B"})). If one row could match both conditions, subtract the overlap so it isn’t counted twice.
How many conditions can COUNTIFS handle?
Up to 127 range and criteria pairs, according to Microsoft. In practice, a formula with more than four or five conditions is easier to manage with the conditions stored in cells or with a PivotTable.
Is COUNTIF case-sensitive?
No. “open”, “Open” and “OPEN” are counted as the same. For a case-sensitive count, use =SUMPRODUCT(--EXACT(range,"Open")).
How do I count cells that are not blank?
Use =COUNTIF(range,"<>") or =COUNTA(range). Both count any cell with content, including cells whose formula returns empty text, so use COUNTBLANK to cross-check if formulas are involved.
Can I use COUNTIF with dates?
Yes. Join a comparison operator to a date with &, such as =COUNTIF(A2:A11,">="&DATE(2026,9,15)), and use COUNTIFS with the same range twice for a date range.
Why does my COUNTIF formula return 0?
The usual causes are extra spaces in the data, text criteria without quotes, a cell reference typed inside the quotes, or dates stored as text. Check one matching cell with =LEN() and look at the formula’s colored range outlines.
Do COUNTIF and COUNTIFS work in Google Sheets?
Yes, with the same syntax and wildcards.
Next steps
Start with a single COUNTIF on your own data, check it against a filter, and then turn it into COUNTIFS as your questions get more specific. Store the values you count by in cells so the same formulas can answer next month’s questions. Microsoft’s COUNTIFS function reference and COUNTIF guide list the full syntax and known limits, and if you need to find where the matching cells are rather than how many there are, see how to search for a word in Excel.

Kermit Matthews runs Live2Tech from just outside Philadelphia. He is an IT specialist with over 20 years of experience, from a university help desk to small-business IT, IT management and his own consulting practice, and has written tech guides full time since 2020. Steps are checked against the current software on a real device or the maker’s official documentation. More about Kermit.