Not Equal Zero in Excel: How to Use It
In this article
To filter or flag cells that are not equal to zero in Excel, you use the <> operator, written as <>0, inside a formula, conditional formatting rule, or filter. For example, =A1<>0 returns TRUE if A1 is not zero and FALSE if it is. This guide covers the main ways to use "not equal to zero" in Excel, including formulas, conditional formatting, and filtering.
What You'll Need
- Microsoft Excel (2013 or later for most features; steps are similar in older versions)
- A worksheet with numeric data in one or more columns
- Basic familiarity with entering formulas and using the Ribbon
Step-by-Step
Method 1: Using a Formula to Return TRUE/FALSE
- Click on an empty cell where you want the result to appear (e.g., B2).
- Type an equals sign, then click on the cell you want to test (e.g., A2), then type
<>0. The full formula should look like=A2<>0. - Press Enter. The cell will display TRUE if A2 is not zero, and FALSE if A2 is zero.
- To copy the formula down a column, click the small square at the bottom-right of the cell (the fill handle) and drag it down over the cells where you want the formula.
Method 2: Using COUNTIF to Count Non-Zero Cells
- Select a cell where you want the count to appear.
- Type
=COUNTIF(A2:A100,"<>0")— replaceA2:A100with your actual range. - Press Enter. Excel counts all cells in the range that are not equal to zero. Text cells are counted as well, because text is not zero.
Method 3: Conditional Formatting to Highlight Non-Zero Cells
- Select the range of cells you want to format (e.g., A2:A100).
- Go to the Home tab, click Conditional Formatting, then New Rule.
- Choose Use a formula to determine which cells to format.
- In the formula box, enter
=A2<>0(use the top-left cell of your selected range as the reference). - Click Format, choose a fill color or font style, then click OK twice.
- All cells in the range that are not zero will now be highlighted.
Method 4: Filtering Out Zero Values
- Select the column header and the data range, then go to the Data tab and click Filter (or press Ctrl+Shift+L).
- Click the drop-down arrow in the column header.
- Uncheck 0 (zero) in the list of values, or choose Number Filters > Does Not Equal and enter
0. - Click OK. Only rows where the column is not zero will remain visible.
Method 5: Using IF to Return a Custom Label
- In a new column, type
=IF(A2<>0,"Non-Zero","Zero"). - Press Enter and copy down. This gives you a readable label instead of TRUE/FALSE.
Common Mistakes
- Using the wrong operator: Some users type
=!0or=/=0. Excel only recognises<>as "not equal to". - Forgetting quotes in COUNTIF: The criteria must be in quotes, like
"<>0", not<>0. - Mixing up text and numbers: A cell with a space or text is not zero, so it will be counted as "not zero". If you only want numeric non-zero cells, you need a more complex formula like
=COUNTIFS(A2:A100,"<>0",A2:A100,"<>""")or useSUMPRODUCT. - Applying conditional formatting to the wrong range: The formula reference must match the top-left cell of the selected range. If you select A2:A100, the formula should start with A2.
Tips
- Use
=A2<>0in a helper column to quickly see which rows are non-zero, then sort or filter by that column. - In COUNTIF, the criteria is case-insensitive and treats text as non-zero. If you need to exclude text as well, use
=SUMPRODUCT((A2:A100<>0)*(ISNUMBER(A2:A100))). - For large datasets, use Excel Tables (Ctrl+T) so formulas and filters automatically extend to new rows.
- When using conditional formatting, consider using a light fill colour so the data remains readable.
Troubleshooting
If the formula returns #VALUE! or #NAME? Check that you haven't typed extra spaces or used the wrong operator. Make sure the cell reference is valid and the sheet name is spelled correctly if you reference another sheet.
If COUNTIF returns 0 but you see non-zero values: The cells might contain text that looks like numbers, or they might have leading apostrophes. Use =ISNUMBER(A2) to check if a cell is numeric. If not, convert text to numbers using the "Text to Columns" feature or by multiplying by 1.
If conditional formatting doesn't highlight anything: Verify that the formula is correct and that the range selection matches the formula reference. Also check that the cells are not formatted as text — if they are, Excel may treat them as text and the comparison may not work as expected. Select the cells, go to the Home tab, and change the number format to General.
If filtering doesn't show the "Does Not Equal" option: This option appears only in the Number Filters submenu for numeric columns. If your column contains text, you'll see Text Filters instead. In that case, use the checkbox list to uncheck 0.
Frequently Asked Questions
How do I write "not equal to zero" in Excel?
Use <>0. For example, =A1<>0 returns TRUE if A1 is not zero.
Does <>0 include blank cells?
Yes, blank cells are not equal to zero, so they return TRUE. If you want to exclude blanks, use =AND(A1<>0,A1<>"").
Can I use <>0 in conditional formatting?
Yes, as shown in Method 3. Enter =A2<>0 as the formula rule.
How do I count non-zero cells in a range?
Use =COUNTIF(range,"<>0"). For example, =COUNTIF(A2:A100,"<>0").
Why does my COUNTIF count text cells as non-zero?
Because text is not equal to zero. If you want to count only numeric non-zero cells, use =SUMPRODUCT((range<>0)*(ISNUMBER(range))).
What if I want to highlight only positive non-zero numbers?
Use =A2>0 in conditional formatting, or =COUNTIF(range,">0") to count positive numbers.