COUNTIF Not Equal To: Count Cells That Don't Match
By ExcelReady TeamUpdated 7 min read
The short answer
To count cells that are not equal to something, put <> in front of the value inside quotes: =COUNTIF(C2:C9,"<>Shipped"). To use a cell instead, join it with &: =COUNTIF(C2:C9,"<>"&F1). Blank cells count as "not equal", so add a second condition with COUNTIFS, "<>", if you want to skip them.
Key takeaways
- Not equal to in Excel is <>, written inside the quotes: "<>Shipped".
- For a cell value, keep <> in quotes and join the cell with &: "<>"&F1.
- "<>Shipped" also counts blank cells. Add a "<>" condition in COUNTIFS to leave them out.
- To exclude two values, use COUNTIFS with the same range twice: one "<>" condition for each value.
On this page+
To use COUNTIF for "not equal to", put <> in front of the value inside the quotes: =COUNTIF(C2:C9,"<>Shipped") counts every cell that is anything other than Shipped. The same idea works with a cell reference, with numbers and with several values to exclude. This guide is for anyone who needs to count "everything except" in a report or a job test, and it points out the blank-cell trap that catches most people.
How to write a COUNTIF not equal to formula#
Write the not-equal sign, <>, directly before the value, and put both inside one pair of double quotes. The pattern is:
=COUNTIF(range,"<>value")All the examples use this order list in A1:D9. Order O-105 has no status yet, so C6 is empty:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Region | Status | Amount |
| 2 | O-101 | North | Shipped | 120 |
| 3 | O-102 | South | Pending | 80 |
| 4 | O-103 | East | Shipped | 200 |
| 5 | O-104 | North | Cancelled | 50 |
| 6 | O-105 | West | 95 | |
| 7 | O-106 | South | Shipped | 150 |
| 8 | O-107 | East | Pending | 60 |
| 9 | O-108 | North | Shipped | 175 |
To count the orders that are not from the North region:
=COUNTIF(B2:B9,"<>North")The result is 5: two South, two East and one West. COUNTIF is not case-sensitive, so "north" in a cell would also be left out. The COUNTIF function guide has the full syntax.
Why <> means not equal to#
In Excel, <> is the not equal to operator: "less than or greater than", which means "different from". It is one of six comparison operators:
| Operator | Meaning | COUNTIF criteria |
|---|---|---|
= | Equal to | "Shipped" or "=Shipped" |
<> | Not equal to | "<>Shipped" |
> | Greater than | ">100" |
< | Less than | "<100" |
>= | Greater than or equal to | ">=100" |
<= | Less than or equal to | "<=100" |
The != sign from programming languages does not work in Excel, and neither does =!. The guide to Excel comparison operators shows each one in formulas, and the lesson on TRUE, FALSE and comparisons lets you try them.
The blank-cell trap#
A blank cell is "not equal to Shipped", so COUNTIF counts it. On the order list:
=COUNTIF(C2:C9,"<>Shipped")The result is 4: two Pending, one Cancelled and the empty status of O-105. That is often what you want, because an order with no status is certainly not shipped. But if you only want to count orders with some other status, leave the blanks out with COUNTIFS and a second "not blank" condition:
=COUNTIFS(C2:C9,"<>Shipped",C2:C9,"<>")The result is now 3. On its own, "<>" means "not equal to nothing", which is how Excel says "not blank". The guide to COUNTIF not blank covers that criteria in more detail.
How to count cells not equal to a cell value#
To compare against a value in another cell, keep <> in quotes and join the cell with the & sign. If F1 holds the word Pending:
=COUNTIF(C2:C9,"<>"&F1)The result is 6: four Shipped, one Cancelled and the blank. Change F1 to Shipped and the answer updates to 4.
Two versions of this formula look right but fail:
=COUNTIF(C2:C9,"<>F1")counts cells that are not the text "F1". Every cell qualifies, so you get 8.=COUNTIF(C2:C9,<>F1)is not a valid formula. Excel shows an error message before you can even press Enter.
If you fill the formula down a summary table, lock the range with $: =COUNTIF($C$2:$C$9,"<>"&F1).
How to exclude two or more values#
COUNTIF takes only one condition, so to exclude two values use COUNTIFS with the same range twice. To count orders that are neither Shipped nor Cancelled:
=COUNTIFS(C2:C9,"<>Shipped",C2:C9,"<>Cancelled")The result is 3: the two Pending orders and the blank one. COUNTIFS uses AND logic, so a cell is counted only when it passes every condition. Add a third pair to exclude a third value.
You can also mix "not equal to" with other conditions. North orders that are not Shipped:
=COUNTIFS(B2:B9,"North",C2:C9,"<>Shipped")That returns 1 (O-104, Cancelled). The COUNTIFS function guide and the COUNTIFS and SUMIFS lesson cover multi-condition counts step by step.
A common slip is to write two COUNTIFs and subtract or add them. =COUNTIF(C2:C9,"<>Shipped")+COUNTIF(C2:C9,"<>Cancelled") returns 4 + 7 = 11, more than the number of orders, because each COUNTIF counts the other's rows.
Not equal to a number, zero or partial text#
Numbers work the same way, with or without a cell:
| Question | Formula | Result |
|---|---|---|
| Amount is not 50 | =COUNTIF(D2:D9,"<>50") | 7 |
| Amount is not 0 | =COUNTIF(D2:D9,"<>0") | 8 |
| Status does not contain "pend" | =COUNTIF(C2:C9,"<>*pend*") | 6 |
The last one uses the * wildcard, which stands for any characters. "<>*pend*" excludes every cell that contains "pend" anywhere. Like the other examples, it still counts the blank status.
COUNTIF ignores capitals, so "<>shipped" also leaves out "Shipped" and "SHIPPED". If case matters, for example with product codes, use EXACT inside SUMPRODUCT instead:
=SUMPRODUCT(--NOT(EXACT(C2:C9,"Shipped")))EXACT returns TRUE only for a perfect match, including capitals. NOT flips each result, and the double minus turns TRUE and FALSE into 1 and 0 for SUMPRODUCT to add. On this data the result is 4, the same as before, because every status is typed the same way.
The same <> criteria work in SUMIF and SUMIFS when you want a total instead of a count. See SUMIF not equal to and SUMIFS not equal to.
Check your result: total minus matches#
A quick way to check any "not equal to" count is to take the total number of rows and subtract the matches:
=ROWS(C2:C9)-COUNTIF(C2:C9,"Shipped")This gives 8 − 4 = 4, the same as "<>Shipped". If your two answers differ, look for extra spaces in the data: "Shipped " with a trailing space is not equal to "Shipped", so it is counted when you don't expect it. The COUNTIF guide lists the other reasons counts go wrong.
Practise it#
Try the exercise on this page: it counts the orders that are not from the North region. Then practise COUNTIF in a live spreadsheet, where you type each criteria and get instant feedback. When you're ready for two conditions, move on to the COUNTIFS and SUMIFS lesson.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
How many orders are not from the North region? Click G2 and use COUNTIF with "<>North" on the Region column (B2:B9), then press Enter.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Amount | |||||||
| 2 | Not North | |||||||
| 3 | ||||||||
| 4 | ||||||||
| 5 | ||||||||
| 6 | West | |||||||
| 7 | ||||||||
| 8 | ||||||||
| 9 | ||||||||
| 10 | ||||||||
| 11 | ||||||||
| 12 |
Tip: The range is B2:B9. The criteria is <> and North together inside one pair of double quotes.
Practise this in a lesson
Frequently asked questions
How do I use COUNTIF for not equal to?
Put the not-equal sign <> before the value, all inside double quotes: =COUNTIF(C2:C9,"<>Shipped"). It counts every cell in the range that is anything other than Shipped, including blank cells.
How do I count cells not equal to multiple values?
Use COUNTIFS and repeat the range, once for each value: =COUNTIFS(C2:C9,"<>Shipped",C2:C9,"<>Cancelled"). Every condition must be true, so a cell is counted only if it is neither value.
How do I count cells not equal to another cell?
Join the operator to the cell with an ampersand: =COUNTIF(C2:C9,"<>"&F1). Don't write "<>F1", because inside quotes F1 is just two letters, not a cell reference.
Does COUNTIF not equal to count blank cells?
Yes. A blank cell is not equal to Shipped, so =COUNTIF(C2:C9,"<>Shipped") includes it. To skip blanks, use =COUNTIFS(C2:C9,"<>Shipped",C2:C9,"<>").
Is COUNTIF not equal to case-sensitive?
No. "<>shipped" treats Shipped, SHIPPED and shipped as the same word, so none of them are counted. For a case-sensitive count, use SUMPRODUCT with EXACT.