COUNTIF is one of the most useful functions in Excel โ it counts cells in a range that meet a single condition you define. Where a plain COUNT function simply tallies how many cells contain numbers, COUNTIF lets you ask a targeted question: how many cells in this range contain the word "Pending"? How many values in this column are greater than 1000? How many dates fall after a particular cutoff? COUNTIF answers all of these with a single formula, returning a number that updates automatically when your data changes.
The function belongs to a family of conditional aggregation functions in Excel that includes SUMIF (sum values that meet a condition), AVERAGEIF (average values that meet a condition), and COUNTIFS (count based on multiple conditions simultaneously). Among these, COUNTIF is typically the first one new Excel users encounter โ it's simple in structure, immediately practical, and it teaches the logic of criteria-based formulas that applies to the more advanced members of the family.
Understanding COUNTIF well pays dividends beyond the function itself. The criteria syntax you learn for COUNTIF โ how to write comparison operators like ">100", how to use wildcards like "*North*", how to reference cells as criteria โ transfers directly to SUMIF, AVERAGEIF, COUNTIFS, SUMIFS, and AVERAGEIFS. Mastering COUNTIF means you're already halfway to mastering the rest of the conditional aggregation family. If you're building out your broader Excel formulas knowledge, COUNTIF is the logical starting point for conditional logic.
This guide covers everything you need to use COUNTIF confidently: the full syntax explanation, worked examples across common use cases, the comparison with COUNTIFS for multi-criteria situations, and the most common mistakes โ with fixes for each.
=COUNTIF(range, criteria)"" as criteria to count blanks; use "<>" to count non-blanksClick the cell where you want the count to appear. This can be anywhere on the sheet โ typically below or beside the data you're counting, or in a summary area. Type an equals sign (=) to start the formula, then type COUNTIF and an opening parenthesis.
Select or type the range of cells you want to count from. For a column of data in A2 to A100, type A2:A100. For a block, type A2:C50. Press F4 after selecting the range if you plan to copy the formula โ this locks the reference with dollar signs (e.g., $A$2:$A$100) so it doesn't shift when copied.
After the range, type a comma, then your criteria. Text criteria must be in double quotes: "Pending", "Yes", "London". Number criteria can be plain numbers: 42. Comparison operators must be inside quotes with the operator: ">100", "<>0", ">=500". Cell references don't need quotes โ just type the cell address or click it.
Type a closing parenthesis and press Enter. Excel returns the count immediately. If you see a #VALUE! error, check that your criteria text is properly quoted and your range is valid. If the result seems wrong, double-check that you're searching the right range and that the criteria matches the exact text or number format used in the data.
The full syntax for COUNTIF is: =COUNTIF(range, criteria). Both arguments are required โ COUNTIF with only one argument returns an error. Understanding each argument in depth helps you use the function correctly across the many different situations you'll encounter.
The range argument is the group of cells you want to count from. This can be a single column (A:A for the entire column A, or A2:A100 for rows 2-100), a single row (1:1 or A1:Z1), or a rectangular block of cells (A2:C50). COUNTIF does not support non-contiguous ranges โ you can't use comma-separated ranges like A2:A100,C2:C100 the way some other functions allow. If you need to count across multiple non-contiguous ranges, you sum two separate COUNTIF formulas: =COUNTIF(A2:A100,criteria)+COUNTIF(C2:C100,criteria).
The criteria argument defines what you're counting for. This is the argument where most of COUNTIF's flexibility lives. Here are the main forms it can take: a literal text string in double quotes ("Complete"), a literal number without quotes (42), a comparison expression in quotes (">500", "<>0", ">=100"), a wildcard pattern in quotes ("*Smith", "Jan*", "*budget*"), a date in quotes formatted as text ("1/15/2026"), or a cell reference (D2) pointing to a cell that contains the value or text you want to match.
When using cell references as criteria, you can also combine them with comparison operators using the ampersand (&) concatenation operator. To count values greater than the value in cell D2, write ">"&D2 as the criteria argument โ the operator is in quotes, then the & joins it to the cell reference.
This technique makes COUNTIF dynamic: when D2 changes, the count updates automatically without editing the formula. A solid working knowledge of these patterns makes COUNTIF a much more powerful tool than it first appears, and the same patterns apply across the conditional formatting rules and other criteria-based features in Excel.
Count how many cells contain a specific word or phrase. Example: =COUNTIF(B2:B200,"Approved") counts all cells in B2:B200 that contain exactly the text Approved. COUNTIF is not case-sensitive, so Approved, APPROVED, and approved are all counted. Make sure the criteria text matches exactly what appears in your data โ trailing spaces in cells are a common cause of unexpected zero counts.
Count numeric values that meet a threshold. Example: =COUNTIF(C2:C500,">1000") counts all cells in C2:C500 with values greater than 1000. Supported operators: > (greater than), < (less than), >= (greater than or equal), <= (less than or equal), <> (not equal to). For "not equal to text": =COUNTIF(A2:A100,"<>Cancelled") counts everything except Cancelled.
Use * (any sequence of characters) and ? (any single character) to count partial matches. =COUNTIF(A2:A100,"*North*") counts any cell containing the word North anywhere in the text. =COUNTIF(A2:A100,"Jan*") counts cells starting with Jan. =COUNTIF(A2:A100,"???-Code") counts cells where any 3 characters are followed by -Code. Wildcards only work with text values, not numbers or dates.
Count empty or populated cells in a range. =COUNTIF(A2:A100,"") counts blank cells (cells with no content). =COUNTIF(A2:A100,"<>""") counts non-blank cells. Note: COUNTBLANK(A2:A100) is a simpler alternative for counting blanks. Cells containing spaces or zero-length strings may behave unexpectedly โ use TRIM and LEN checks if blank detection seems incorrect.
Common COUNTIF formulas for counting text values in your data.
=COUNTIF(A2:A100,"London") โ counts cells containing exactly London=COUNTIF(A2:A100,"<>Cancelled") โ counts everything except Cancelled=COUNTIF(A2:A100,"Mar*") โ counts cells starting with Mar (March, Marketing, Mario, etc.)=COUNTIF(A2:A100,"*pending*") โ counts cells containing the word pending anywhere=COUNTIF(A2:A100,"*Ltd") โ counts cells ending with Ltd=COUNTIF(A2:A100,D1) โ counts cells matching whatever text is in cell D1; update D1 to change the search term=COUNTIF(A2:A100,"") โ counts empty cellsCOUNTIF formulas for counting numbers that meet specific thresholds or conditions.
=COUNTIF(B2:B100,0) โ counts cells containing exactly zero=COUNTIF(B2:B100,">1000") โ counts values above 1000=COUNTIF(B2:B100,"<=500") โ counts values 500 and below=COUNTIF(B2:B100,"<>0") โ counts all non-zero values=COUNTIF(B2:B100,">"&C1) โ counts values greater than whatever is in cell C1; change C1 to update the threshold automatically=COUNTIF(B2:B100,">100")-COUNTIF(B2:B100,">500") counts values between 100 and 500COUNTIF formulas for counting dates โ including before, after, and relative to today.
=COUNTIF(C2:C100,"1/15/2026") โ counts cells with that exact date (use the date format matching your regional settings)=COUNTIF(C2:C100,">"&DATE(2026,1,1)) โ counts dates after January 1, 2026=COUNTIF(C2:C100,"<"&TODAY()) โ counts past dates; updates dynamically every day=COUNTIF(C2:C100,">="&DATE(2026,1,1))-COUNTIF(C2:C100,">="&DATE(2027,1,1)) โ counts dates in 2026=COUNTIF(C2:C100,">"&D1) โ counts dates after the date in D1; change D1 to adjust the filterCOUNTIF accepts only one criteria range and one criterion โ that's its core limitation. When you need to count based on two or more conditions simultaneously, you need COUNTIFS. The syntax for COUNTIFS extends the COUNTIF pattern by accepting pairs of range-criteria arguments: =COUNTIFS(range1, criteria1, range2, criteria2, ...). You can add as many range-criteria pairs as your condition requires, up to 127 pairs.
To illustrate the difference: if you have a sales table with a Region column (A) and a Status column (B), and you want to count rows where Region is "North" AND Status is "Complete", COUNTIF can't do it โ it can only check one column.
COUNTIFS handles it cleanly: =COUNTIFS(A2:A100,"North",B2:B100,"Complete"). All conditions in COUNTIFS use AND logic โ every condition must be true for a row to be counted. If you need OR logic (count where Region is North OR Status is Complete), the correct approach is to sum two separate COUNTIF or COUNTIFS formulas, being careful to avoid double-counting rows that match both conditions.
A common pattern is combining COUNTIFS with date criteria to count activity in a specific period โ for example, counting orders placed in Q1 of 2026 with a status of Shipped: =COUNTIFS(C2:C100,">="&DATE(2026,1,1),C2:C100,"<"&DATE(2026,4,1),B2:B100,"Shipped"). This kind of multi-criteria counting is where COUNTIFS genuinely shines, and it's one of the most frequently used patterns in financial and operational reporting spreadsheets. You'll find similar criteria logic used in Excel pivot tables when filtering by multiple dimensions โ understanding COUNTIFS deepens your intuition for how Excel handles conditional filtering generally.
Both COUNTIF and COUNTIFS have an important limitation: they don't support non-contiguous ranges within a single criteria pair. Each criteria range in a COUNTIFS must be a single, contiguous block, and all criteria ranges must be the same size as each other. If your data is structured in multiple separate blocks, you'll need to either restructure the data or use a helper column to combine the criteria into a single range before applying COUNTIFS. For more complex conditional aggregation across irregular data structures, Excel's array formulas with SUMPRODUCT offer an alternative that's more flexible, if more complex to write.
Even experienced Excel users run into predictable pitfalls with COUNTIF. Knowing the most common mistakes โ and their fixes โ saves significant debugging time when a formula produces unexpected results.
The most frequent mistake is forgetting quotes around text criteria or comparison operators. COUNTIF requires that any text string or expression using a comparison operator (>, <, >=, <=, <>) be enclosed in double quotes. Writing =COUNTIF(A2:A100,>100) returns a #VALUE! error; writing =COUNTIF(A2:A100,">100") works correctly. Numbers used as exact match criteria don't need quotes โ =COUNTIF(A2:A100,42) is fine โ but the moment you add an operator, quotes are required.
The second most common problem is criteria that doesn't match the data. COUNTIF returns zero when your criteria text doesn't exactly match the cell content, even if it looks identical on screen. Hidden trailing spaces are a frequent culprit โ if someone entered "Complete " (with a trailing space) instead of "Complete", your COUNTIF for "Complete" returns zero for those cells. Fix this by running TRIM on the data range, or use a wildcard: "Complete*" will match Complete, Complete_, and Complete with trailing spaces.
Date matching is another area where COUNTIF behaves unexpectedly. Excel stores dates as serial numbers (integers), and if you type a date in the criteria as a text string โ "1/15/2026" โ it may not match the stored serial number in the cells. The reliable approach is to construct date criteria using the DATE function combined with the & operator: ">="&DATE(2026,1,15). This generates the correct serial number for comparison regardless of your regional date format settings.
Finally, many users don't realise that COUNTIF is not case-sensitive by default โ "apple", "APPLE", and "Apple" all count the same. If you need case-sensitive counting, you have to use an array formula workaround with EXACT: =SUMPRODUCT((EXACT(A2:A100,"APPLE"))*1) counts only cells with exactly the casing "APPLE". This is rarely needed in practice, but it's good to know the limitation exists. Just as XLOOKUP and VLOOKUP treat lookup values case-insensitively, so does COUNTIF โ all of Excel's standard lookup and matching functions share this characteristic.
Once you're comfortable with basic COUNTIF syntax, several advanced techniques extend the function's usefulness significantly. These patterns appear regularly in professional Excel work and are worth adding to your toolkit.
Using COUNTIF to detect duplicates is one of the most practically valuable applications. The formula =COUNTIF($A$2:$A$100,A2) placed in a helper column next to your data tells you how many times the value in each row appears in the entire list. Any row with a count greater than 1 is a duplicate entry.
This pattern is faster than conditional formatting for large datasets and gives you a sortable number you can filter on โ sort by the helper column descending to instantly surface the most duplicated values. You can also use this technique to find items in one list that appear in a second list: =COUNTIF(ListB,A2) returns a positive number if A2 exists in ListB and zero if it doesn't, functioning as a lookup existence check without needing VLOOKUP or XLOOKUP.
Dynamic criteria using cell references make COUNTIF formulas interactive. Instead of hard-coding the criteria in the formula, point the criteria argument to a cell that contains the value you want to match. Then create a dropdown list in that cell using Excel's Data Validation feature โ suddenly your COUNTIF summary updates instantly when a user selects a different option from the dropdown. This pattern is the foundation of simple interactive dashboards where a single dropdown selection filters and recalculates multiple summary metrics simultaneously, without requiring any macros or complex programming.
Combining COUNTIF with SUMPRODUCT enables COUNTIF-style counting with case sensitivity or with OR conditions across multiple columns. =SUMPRODUCT((A2:A100="North")+(B2:B100="North")>0) counts rows where either column A or column B contains "North" โ genuine OR logic that a single COUNTIF or COUNTIFS can't produce. SUMPRODUCT evaluates the logical arrays and sums the results, giving you the flexibility of COUNTIF with the structural flexibility of array formulas. For very large datasets (hundreds of thousands of rows), SUMPRODUCT can be slower than COUNTIFS, so use COUNTIFS with carefully designed OR decomposition for performance-critical situations.
COUNTIF also integrates naturally with named ranges, making formulas easier to read and maintain. Instead of =COUNTIF($A$2:$A$100,"Complete"), define a named range called StatusColumn for A2:A100, and write =COUNTIF(StatusColumn,"Complete"). When your data expands or the column moves, updating the named range definition automatically updates every formula that references it. Named ranges combined with structured Excel spreadsheet table design โ using Excel Tables (Ctrl+T) with automatic column references โ are the approach professional analysts use to make COUNTIF formulas that stay correct as data grows and changes over time.
The fastest way to learn COUNTIF is to apply it to a dataset you're actually working with, rather than practising on abstract examples. Take any list you work with regularly โ a project status log, a customer list, an inventory table, an expense tracker โ and start by writing a COUNTIF that counts how many times each distinct value appears in one of the key columns. Even a simple count of how many items are "Complete" versus "In Progress" versus "Pending" immediately makes the function tangible and useful.
Once you've built your first working COUNTIF, push it slightly further: make the criteria dynamic by pointing it at a cell instead of hard-coding the text. Select a nearby cell, type a value that exists in your data, and update your COUNTIF formula to reference that cell as the criteria. Watch the count change when you type a different value. This single step โ moving from static to dynamic criteria โ is the conceptual breakthrough that unlocks COUNTIF's value for real-world reporting.
The next natural progression is COUNTIFS. Once you have a COUNTIF working, add a second condition: count the same thing, but only for a specific region, date range, or category. The syntax extension from COUNTIF to COUNTIFS is minimal โ you just add another comma-separated range-criteria pair โ but the analytical power increases significantly. Most professional Excel work that involves conditional counting uses COUNTIFS rather than COUNTIF, precisely because real business questions almost always involve more than one filter.
Treat any COUNTIF result of zero that you didn't expect as a learning opportunity rather than a bug to ignore. Investigate why: check the data for trailing spaces, verify the number format, confirm you're looking at the right range. Each investigation teaches you something about how Excel stores and compares data that makes you a more effective spreadsheet analyst.
The debugging skills you develop with COUNTIF transfer to every other function you use, because the underlying data-matching logic is consistent across Excel's entire function library. That transferability is one of the reasons COUNTIF is such a valuable function to truly master early in your Excel learning journey.
If you're working in a shared Excel environment โ where colleagues also edit the same workbooks โ it's worth formatting your COUNTIF ranges as official Excel Tables (Ctrl+T). Table references like =COUNTIF(Table1[Status],"Complete") automatically expand as new rows are added, eliminating the brittle fixed-range problem that causes COUNTIF formulas to silently miss newly added data. Consistently adopting this habit alone prevents a significant and recurring category of reporting errors in collaborative Excel files used by multiple people.