To count cells that contain one specific text value in Excel, use =COUNTIF(A2:A20,"Paid"). This counts cells in A2:A20 whose entire value is Paid, ignoring capitalization; replace the range and text with your own.
How COUNTIF matches text
COUNTIF applies one condition to a range and returns the number of cells that meet it. Its syntax is =COUNTIF(range, criteria): the range is where Excel looks, and the criteria is what it looks for. When the criterion is text, put the text in straight double quotes.
For example, if A2:A20 contains order statuses and you want to count entries labeled Shipped, use =COUNTIF(A2:A20,"Shipped"). The formula returns a number, not a list of matching cells. You can place it in another cell, such as B2, and press Enter.
COUNTIF is not case-sensitive. It treats Shipped, shipped, and SHIPPED as the same criterion. It does, however, distinguish a whole-cell match from a partial match: the criterion “Ship” does not count the cell Shipped unless you add wildcards.
Use a cell reference instead of typing the text
A cell reference is useful when the text to count may change. Suppose statuses are in A2:A20 and the value to look for is entered in D2. Use =COUNTIF(A2:A20,D2). If D2 contains Paid, the result is the count of cells equal to Paid. There are no quotation marks around D2 because it is a reference, not text typed directly into the formula.
This approach also makes a small summary table easy to maintain: list the statuses you want to measure in D2:D5, then enter the formula beside the first status and copy it down. With statuses in A2:A20 and the first criterion in D2, use =COUNTIF($A$2:$A$20,D2). The dollar signs keep the data range fixed as you fill the formula down, while D2 adjusts to D3, D4, and so on.
Count text that contains a word or phrase
Use the asterisk wildcard when the target text can appear alongside other characters. An asterisk represents any number of characters, including none. For example, to count cells containing the word North anywhere within their text, use =COUNTIF(A2:A20,"*North*"). This can count North region, Region North, and North-West.
Other useful patterns include:
=COUNTIF(A2:A20,"North*")counts cells that begin with North.=COUNTIF(A2:A20,"*North")counts cells that end with North.=COUNTIF(A2:A20,"A?C")counts three-character values that start with A and end with C, with any single character in between.
The question mark is a wildcard for exactly one character. If you need to search for a literal asterisk or question mark rather than use it as a wildcard, put a tilde before it in the criterion: for example, =COUNTIF(A2:A20,"~*" ) counts cells whose entire value is an asterisk. A tilde itself is represented by two tildes.
Build criteria with text and operators
COUNTIF can also compare values using operators such as not equal to. To count cells that are not equal to the text Paid, use =COUNTIF(A2:A20,"<>Paid"). In an Excel formula, the criterion is written as the text string “<>Paid”; the HTML characters shown here render as the less-than and greater-than symbols in Excel.
You can combine an operator with a cell reference using the ampersand (&) to join the pieces. With statuses in A2:A20 and a criterion in D2, count cells not equal to D2 using =COUNTIF(A2:A20,"<>"&D2). This is different from writing the operator and reference together inside quotation marks, which would make Excel treat the reference as literal text.
Be aware that a not-equal criterion can include blank cells. If you want to count values other than Paid but exclude blanks, use =COUNTIFS(A2:A20,"<>Paid",A2:A20,"<>"). COUNTIFS applies both conditions to the same range: the cell must not be Paid and must not be empty.
Common problems and checks
- Unexpected zero: Check spelling, spaces, and whether you intended an exact or partial match. A trailing space in a cell, such as Paid followed by a space, can prevent an exact match. TRIM can help clean ordinary extra spaces, but it does not remove every kind of invisible character.
- Formula shows as text: Confirm the cell is not formatted as Text. Change its number format to General, then re-enter the formula. Also check that the formula begins with an equals sign and does not have an apostrophe before it.
- Wrong argument separator: The examples use commas, as specified for standard Excel settings. Some regional settings use semicolons in formulas; if Excel rejects a valid example, use the separator your installation expects.
- Numbers stored as text: A number-looking entry may be stored as text. COUNTIF can distinguish the stored value and the criterion in ways that matter for mixed data, so check the cell format and convert inconsistent entries when appropriate.
- Copied range moves: When copying a formula, lock the data range with dollar signs, such as $A$2:$A$20, if it should remain fixed.
Excel does not require the range and criteria to have identical dimensions for a basic COUNTIF, but keeping the range limited to the relevant data makes the formula easier to understand and can improve workbook responsiveness. If your data is in an Excel table, structured references can make formulas adapt as rows are added; the table column name must match your actual column heading.
COUNTIF versus related options
Use COUNTIF when you have one condition, such as a status matching Paid. Use COUNTIFS when multiple conditions must all be true—for example, a status is Paid and a region is West. With statuses in A2:A20 and regions in B2:B20, count paid orders in the West using =COUNTIFS(A2:A20,"Paid",B2:B20,"West").
If you need to count with case sensitivity, COUNTIF is not the right function by itself. A formula using SUMPRODUCT and EXACT can compare text while distinguishing uppercase and lowercase. With text in A2:A20 and the case-sensitive target Paid, use =SUMPRODUCT(--EXACT(A2:A20,"Paid")). EXACT returns TRUE only for matching text with the same capitalization, and SUMPRODUCT totals those TRUE results as 1s. For ordinary status labels, COUNTIF is simpler and usually the better choice.
For more than one possible value, you can add separate COUNTIF results or use a more tailored formula. For example, adding two COUNTIF formulas counts cells equal to either of two labels, but a cell cannot be equal to both distinct exact labels at once. For complex criteria, first define precisely whether you need “either” or “both”; that determines whether to add counts or use COUNTIFS.
Frequently Asked Questions
Does COUNTIF count text without regard to capitalization?
Yes. COUNTIF is case-insensitive, so a criterion of “Paid” also matches paid and PAID. Use EXACT with SUMPRODUCT when capitalization must matter.
How do I count cells that contain a word anywhere?
Put an asterisk before and after the word in the criterion. For North in A2:A20, use =COUNTIF(A2:A20,"*North*").
Can COUNTIF count a value stored in another cell?
Yes. If the data is in A2:A20 and the target text is in D2, use =COUNTIF(A2:A20,D2). Do not put quotation marks around the cell reference.
How do I count cells that are not blank?
Use =COUNTIF(A2:A20,"<>"). The criterion means “not equal to blank.” Cells containing formulas that return an empty string can behave differently from genuinely empty cells, so check the source data if the result seems unexpected.
Why does COUNTIF return zero when the text looks identical?
The values may differ because of leading or trailing spaces, hidden characters, or a spelling variation. Compare the source and criterion carefully, and clean inconsistent text before counting if needed.
Related
- Google Sheets COUNTIF for Specific Text
- Google Sheets: Count Cells With a Specific Dropdown Value
- Google Sheets: Count Cells With Specific Text in a Range
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Excel INDIRECT: Reference Cells on Another SheetYes. In Excel for Microsoft 365, INDIRECT can turn a text reference into a reference to a cell…
- Excel Conditional Formatting With a Custom FormulaTo use a custom formula in Excel conditional formatting, select the cells to format, then choose Home >…
- Concat Excel Columns: Formulas, Methods, and Fixes ExplainedTo concat Excel columns—that is, join values from separate cells into one—use the ampersand operator. With first names…
- Excel XLOOKUP With Multiple Criteria: Formulas & TipsTo use XLOOKUP with multiple criteria in Excel, multiply the criteria tests to require every condition to be…
- Power Query Splitter Functions and When to Use ThemPower Query splitter functions divide text at delimiters, specified characters, or other boundaries. For a simple exact separator,…
- Excel Loan Payment Formula: How to Use PMTFor a fixed-rate loan with monthly payments, Excel’s PMT function calculates the regular payment. If B1 contains the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.