The short answer: use the COUNTIF function with the "not equal to" operator (<>) and a text value in quotes, like =COUNTIF(A1:A10,"<>Pending"). This counts every cell in the range that does not contain the exact text "Pending" (including blanks). For a more flexible match that treats empty cells as "not equal" but excludes them from the count, use =COUNTIFS with an extra condition. This guide walks through both approaches, plus how to handle partial matches, case sensitivity, and cells that look empty but aren't.
What You'll Need
- Microsoft Excel 2010 or later (the steps work the same in Excel 365, Excel 2021, 2019, and 2016).
- A worksheet with a column of text values (e.g., statuses, names, categories) you want to count.
- Basic familiarity with typing formulas into a cell — you don't need to be an expert.
Step-by-Step
- Identify the range and the text you want to exclude. For example, suppose column A has a list of order statuses: "Shipped", "Pending", "Delivered", and some blank cells. You want to count how many are not "Pending".
- Click an empty cell where you want the result to appear (e.g., C1).
- Type the formula
=COUNTIF(A:A,"<>Pending")and press Enter. ReplaceA:Awith your actual range (e.g.,A2:A100if your data starts in row 2). The operator<>means "not equal to" in Excel, and the text must be in double quotes. - Check the result. Excel counts every cell in the range that is not exactly "Pending". This includes blank cells, cells with other text, and cells with numbers. If you want to exclude blanks as well, use the next step.
- To exclude blank cells too, use COUNTIFS with two conditions. Type
=COUNTIFS(A:A,"<>Pending",A:A,"<>")and press Enter. The second condition"<>"means "not empty", so this counts only cells that have some value and that value is not "Pending". - For a case-insensitive match (the default), just use the formula as above — Excel treats "pending" and "PENDING" the same. If you need case-sensitive counting, use
SUMPRODUCTwithEXACT:=SUMPRODUCT(--(EXACT(A:A,"Pending")=FALSE))— but note that this also counts blanks. To exclude blanks, add--(A:A<>")inside:=SUMPRODUCT((EXACT(A:A,"Pending")=FALSE)*(A:A<>"")). - To count cells that do not contain a specific text as part of a longer string (e.g., not containing "Pending" anywhere), use wildcards:
=COUNTIF(A:A,"<>*Pending*"). This counts cells that do not have "Pending" anywhere in the text. Be careful: this still counts blanks. To exclude blanks, use=COUNTIFS(A:A,"<>*Pending*",A:A,"<>"). - If your text contains a wildcard character like an asterisk (*) or question mark (?), and you want to match it literally, prefix it with a tilde (~). For example, to count cells not equal to "*Pending*" (the literal asterisks), use
=COUNTIF(A:A,"<>~*Pending~*"). - Use a cell reference for the text instead of hardcoding it: put "Pending" in a cell (say D1) and use
=COUNTIF(A:A,"<>"&D1). This makes it easy to change the excluded value without editing the formula. - For multiple exclusions (e.g., count cells that are neither "Pending" nor "Cancelled"), use
=COUNTIFS(A:A,"<>Pending",A:A,"<>Cancelled"). Each pair of range and criteria adds a condition, and all must be true for a cell to be counted.
Common Mistakes
- Forgetting the quotes around the text.
=COUNTIF(A:A,<>Pending)is invalid — you must write"<>Pending". - Using the wrong operator. The not-equal operator is
<>, not!=or¬=. Excel only understands<>. - Expecting COUNTIF to ignore blanks. By default,
COUNTIFwith "not equal to" counts blank cells because blank is not equal to the text. If you don't want blanks counted, you must add the second condition as shown. - Mixing up text and numbers. If your range contains numbers and you write
"<>5", Excel counts cells that are not the number 5, including text cells. That's usually fine, but be aware. - Using wildcards when you don't need them. If you write
"<>*Pending*", it counts cells that do not contain "Pending" anywhere. If you meant "not exactly Pending", you'll get a different result — for example, "Pending Now" would be counted as not equal to "Pending" but would not be counted with the wildcard version because it contains "Pending".
Tips
- Use a table or named range to make your formula easier to read and maintain. If your data is in a table (Insert > Table), you can use structured references like
=COUNTIF(Table1[Status],"<>Pending"). - Test with a small range first. Before applying to a huge column, try
=COUNTIF(A1:A10,"<>Pending")to verify the logic. - Combine with other functions. For example,
=SUMPRODUCT((A:A<>"Pending")*(A:A<>""))gives the same result as the COUNTIFS version and can be extended with more conditions. - Remember that COUNTIF is not case-sensitive. If you need case-sensitive matching, use the SUMPRODUCT/EXACT approach.
- Use the Formula Bar to edit — it's easier to see the whole formula and avoid typos.
Troubleshooting
If the formula returns a #NAME? error: This usually means you misspelled the function name or used a comma instead of a semicolon (in some locales, Excel uses semicolons as argument separators). Check the function name and the separators.
If the result is higher than expected: You're probably counting blank cells. Add the second condition "<>" to exclude blanks, or check if your range includes hidden rows or cells with spaces.
If the result is lower than expected: You might have extra spaces in your text values. For example, "Pending " (with a trailing space) is not equal to "Pending". Use =TRIM(A:A) to clean data, or use wildcards to ignore spaces: "<>*Pending*".
If the formula doesn't update when you change data: Make sure calculation is set to Automatic (Formulas > Calculation Options > Automatic). If it's on Manual, press F9 to recalculate.
If you get a #VALUE! error: This can happen if your range includes errors or if you're using array formulas incorrectly. Try simplifying the formula or using IFERROR if needed.
If the wildcard version doesn't work as expected: Remember that wildcards only work with text. If your range contains numbers, they won't match "*Pending*" at all, so they'll all be counted as "not containing Pending".
Frequently Asked Questions
Does COUNTIF count blank cells when using "not equal to"?
Yes, by default COUNTIF with <>text counts blank cells because a blank is not equal to the text. To exclude blanks, add a second condition with "<>" (not empty) using COUNTIFS.
How do I count cells that are not equal to one of several text values?
Use COUNTIFS with multiple criteria: =COUNTIFS(A:A,"<>Pending",A:A,"<>Cancelled"). Each pair adds a condition, and all must be true for a cell to be counted.
Can I use a cell reference for the text in COUNTIF?
Yes, concatenate the operator with the cell reference: =COUNTIF(A:A,"<>"&D1) where D1 contains the text you want to exclude.
Is COUNTIF case-sensitive?
No, COUNTIF is not case-sensitive. "Pending", "pending", and "PENDING" are treated as the same. For case-sensitive counting, use SUMPRODUCT with EXACT.
How do I count cells that do not contain a specific text anywhere?
Use wildcards: =COUNTIF(A:A,"<>*Pending*"). This counts cells that do not have "Pending" as a substring. To exclude blanks, use COUNTIFS with an additional "<>" condition.
What if my text contains an asterisk or question mark?
Prefix the wildcard character with a tilde (~) to treat it as a literal. For example, =COUNTIF(A:A,"<>~*Pending~") counts cells not equal to the literal string "*Pending*" (without the tilde).