To count cells that are not equal to a value, use =COUNTIF(A1:A10,"<>0"). The <> operator means “not equal to”, and the whole criteria must sit inside double quotes.
To compare against a cell instead of a hard-coded value, join them with & — =COUNTIF(A1:A10,"<>"&C1). For text, use =COUNTIF(A1:A10,"<>Apple"), but remember it counts blank cells too, since a blank is technically not equal to “Apple”.
To leave blanks out, use =COUNTIFS(A1:A10,"<>Apple",A1:A10,"<>") or subtract COUNTBLANK. And for more than one condition, switch to COUNTIFS: =COUNTIFS(A1:A10,"<>0",B1:B10,"<>North").
Let’s say you are a teacher managing a class’s test scores in Excel. You want to identify how many students scored something other than a zero, as zero might indicate that the student was absent or did not complete the test. In this case, COUNTIF can help you.
Having used it a lot, I have realized that the COUNTIF function is the best way to count the cells that are not equal to a specific value you define.
You just need to specify the range of values to check and the criteria that you want to test. That’s it.
In the following example, you have a list of values in the form of numbers, and from here, you need to count the number of values that are not equal to zero.

Formula: COUNTIF Not Equal To
You can use the formula below to count the number of cells in the range from A2 to A15 that are not equal to zero.
=COUNTIF(A2:A15,"<>0")
- First, you need to enter the COUNTIF function in cell C1 and type an opening parenthesis.

- Next, select the range from which you want to count the values.

- After that, type a comma to move to the next argument.
- In the end, enter “<>0” in the criteria and close the parenthesis.

When you hit Enter, it returns the count of the cells that are not equal to zero.
Just keep in mind that “<>0” counts every cell that isn’t zero, including blank cells and cells with text. If your range has blanks and you only want to count the cells with a value, add a second condition with COUNTIFS that skips the empty cells:
=COUNTIFS(A2:A15,"<>0",A2:A15,"<>")
And if you want to count only the numbers that are not zero (ignoring text as well), use SUMPRODUCT with ISNUMBER:
=SUMPRODUCT(--ISNUMBER(A2:A15),--(A2:A15<>0))

As you can see, you have used the symbol <> (Does Not Equal) before the zero. This symbol is a combination of the less than and greater than signs, and when you use both signs together, it means “not equal to”.
Read Also – How to Count Colored Cells in Excel (Using a Formula)
Here’s How This Formula Works
To understand this formula, you need to split it into two parts:
- (A2:A15): This part of the formula specifies the range that the formula needs to check.
- “<>0”: This tells the formula to look for any cell that doesn’t have a zero in it.
Count Cells Not Equal to a Specific Number
Now, instead of zero, you can also use any other number in the condition, as we have in the below formula:
=COUNTIF(A2:A15, "<>10")
Here’s How It Works
The range A2:A15 tells Excel to look at the cells from A2 up to A15. “<>10” sets the condition for counting the cells not equal to 10. The formula goes through each cell in the range A2 to A15 and checks if the value is not equal to 10. Each time this condition is TRUE, Excel counts it.
Next Read – Excel COUNTIF Blank / COUNTIFS Between Two Numbers / COUNTIF Not Equal To
Count Not Equal to a Text String
The same formula can be used to count the cells where the text value is not equal to a specific text. Have a look at the below formula:
=COUNTIF(A2:A15, "<>Hello")
Here’s How This Formula Works
This formula counts how many cells in the range A2 to A15 don’t have the text “Hello”. It checks each cell in this range (A2:A15) and counts it if the cell has a different value than “Hello”. The result tells you the number of cells with a value other than “Hello”. The comparison is not case-sensitive, so “hello” is also left out, and blank cells are counted.
Use a fixed range like A2:A15 here, not the entire column A:A. With a whole column, every empty cell in the column (over a million of them) is also “not equal to Hello”, and the count becomes huge.
COUNTIF Not Equal to a Date
The same thing goes with a date. If you have a date which you want to use as a criterion, COUNTIF will do that for you. Here’s the formula that you can use:
=COUNTIF(A2:A15, "<>1/1/2024")
This formula checks each cell from A2:A15 to see if the value is not the date January 1, 2024. If a cell contains any other date or value, it is counted. This gives you the total number of cells that do not have the date January 1, 2024.
A date typed as text in the criteria, like 1/1/2024, is read with your computer’s date settings, so in some regions it can mean a different date. To be safe, build the date with the DATE function:
=COUNTIF(A2:A15,"<>"&DATE(2024,1,1))
COUNTIFS Not Equal To
COUNTIFS is useful when you need to apply AND logic when counting not equal to cells. For example, you can count the cells that are not equal to 10 and also not equal to 20 in the same range of cells.
=COUNTIFS(A2:A15, "<>10", A2:A15, "<>20")
The above formula uses COUNTIFS to count the cells that meet both conditions: the cells do not have the number 10, and they do not have the number 20.
Must Read – COUNTIF Less Than / COUNTIF Greater than 0 / OR Logic in COUNTIF
Not Equal Value from a Cell
Whenever I write a formula like this, where I need to specify a value to create a criterion, I always try to use a cell reference. What I mean is, instead of adding the not equal to value directly into the formula, you can enter it into a cell and then refer to that cell in the formula.
This gives you more flexibility when you need to change the value. You don’t need to change the value in the formula; instead, you just need to go to the cell and change it there.
And especially when you have applied the COUNTIF formula to an entire column, using a cell reference can save you a lot of time, as you don’t need to go to each cell and change the formula.
To use a cell in the condition, join the not equal to sign with the cell using an ampersand. If C1 has the value 10, the following formula counts the cells not equal to 10:
=COUNTIF(A2:A15,"<>"&C1)
Frequently Asked Questions
Why is my COUNTIF not equal count too high?
“Not equal to” also counts blank cells. If you use a whole column or a range with empty cells, add the condition “<>” with COUNTIFS to skip blanks, as shown above.
How do I count cells that are not blank?
Use “<>” on its own as the criteria. It counts every cell that isn’t empty (a formula that returns “” is counted as not empty):
=COUNTIF(A2:A15,"<>")
Is COUNTIF not equal to case-sensitive?
No. “<>Hello” also skips “hello” and “HELLO”. For a case-sensitive count, use SUMPRODUCT with EXACT:
=SUMPRODUCT(--NOT(EXACT(A2:A15,"Hello")))
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.