In Excel, “not equal to” is written as <>. Put it between two values or cell references to test whether they differ; for example, =A2<>B2 returns TRUE when the values in A2 and B2 are not equal and FALSE when they are equal.
What the Excel not-equal operator means
The angle brackets form one comparison operator: the less-than sign followed by the greater-than sign. Excel evaluates the comparison and returns one of two logical values, TRUE or FALSE. The operator does not change a cell or correct a mismatch; it only reports whether the compared values are different.
Use <> in a worksheet formula wherever a comparison is needed, including inside functions such as IF, COUNTIF, and conditional-formatting rules. It is the opposite of Excel’s equals operator, =. Excel does not use != for this test, so typing that common programming-language notation into a formula will not work as the not-equal operator.
For example, if A2 contains 18 and B2 contains 23, the comparison =A2<>B2 returns TRUE. If both cells contain 18, it returns FALSE. A formula result of TRUE or FALSE can then drive another calculation, a message, or a visual highlight.
Compare cells and values in a formula
To compare two cells, place their references on either side of the operator. The following example assumes A2 contains 12 and B2 contains 15. The formula =A2<>B2 returns TRUE because the numbers differ. If B2 also contained 12, the result would be FALSE.
You can also compare a cell with a fixed number or text value. Text in a formula must be enclosed in straight double quotation marks. The next example assumes A2 contains the text Paid. The formula =A2<>"Paid" returns FALSE because A2 matches the word Paid; if A2 contains Pending, it returns TRUE.
Wrap a comparison in IF when you want a readable result instead of TRUE or FALSE. With a status in A2, where A2 contains Pending, =IF(A2<>"Paid","Follow up","Complete") returns Follow up. If A2 contains Paid, the formula returns Complete. This pattern is useful for review flags, status labels, and simple checks in a data-entry sheet.
Comparison formulas also work with dates because Excel stores dates as serial numbers. A date can therefore be checked against another date or a date value produced by a function. Be sure the cells contain real Excel dates, not text that only looks like a date; inconsistent data types can make an otherwise sensible comparison misleading.
Use not equal in COUNTIF and other criteria
In functions that accept a criteria argument, the not-equal operator is written inside a quoted criteria string. For example, COUNTIF can count entries that do not match a specified status. If the values to check are in B2:B7 and E2 contains the status to exclude, the criterion is built by joining the operator text to the cell reference.
Assume B2:B7 contains Paid, Pending, a blank cell, Refunded, Paid, and Pending, in that order, and E2 contains Paid. The formula =COUNTIFS(B2:B7,"<>"&E2,B2:B7,"<>") returns 3: it counts the two Pending cells and the Refunded cell while excluding Paid and the blank. The second condition explicitly excludes empty cells, which makes the intended count clear.
COUNTIF and COUNTIFS are useful when the goal is a count rather than a TRUE/FALSE result. SUMIF and SUMIFS can use criteria in a similar way to add values associated with records that do not match a label. In every case, check whether blank cells should be included or excluded. Criteria can behave differently from a direct comparison, and a formula that counts unintended blanks can distort a summary.
For a fixed criterion, a formula such as =COUNTIF(B2:B7,"<>Paid") expresses “count values not equal to Paid.” If the excluded value may change, a cell reference joined with & avoids rewriting the criterion. The example using COUNTIFS is safer when the range contains blanks and the task is specifically to count nonblank, nonmatching entries.
Not equal to blank: empty cells and empty strings
A frequent question is how to test whether a cell is not blank. A direct comparison with an empty text string is common: =A2<>"". If A2 contains a value such as 0, a date, or ordinary text, this comparison returns TRUE; if A2 is genuinely empty, it returns FALSE.
There is an important distinction between a truly empty cell and a formula that displays nothing. Suppose A2 is completely empty and A3 contains a formula whose result is an empty string, ="". The comparison =A2<>"" returns FALSE for A2, and =A3<>"" also returns FALSE for A3. Both appear empty to this test, even though only A2 is actually blank.
If the distinction matters, use ISBLANK. With A2 genuinely empty and A3 containing a formula that returns an empty string, =ISBLANK(A2) returns TRUE, while =ISBLANK(A3) returns FALSE. Choose the test that fits the question: “does this cell display a nonempty value?” is not always the same as “has anything been entered or calculated in this cell?”
Cells containing spaces are another source of confusion. A cell with one or more spaces is not empty, even if it looks blank on screen. A not-equal-to-empty-string test can treat that cell as nonempty. If imported or manually entered data may contain stray spaces, inspect or clean the source values rather than assuming that visual appearance guarantees a genuinely empty cell.
Highlight values that are not equal
Use conditional formatting when you want Excel to mark differences directly in a worksheet. In Microsoft Excel for Microsoft 365 on Windows, select the cells to format, then choose Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format. Enter a formula beginning with an equals sign, choose a format, and confirm the rule.
For example, to highlight each row in A2:D20 when its status in column A is not Paid, select A2:D20 and use =$A2<>"Paid". The dollar sign fixes the status column as Excel applies the rule across the selected row, while the row number remains relative so it updates for each row. The row containing Pending will meet the condition; a row containing Paid will not.
To highlight mismatches between two columns, select the comparison range and use a relative-reference formula such as =A2<>B2, adjusting the references to match the first row of the selected range. Excel evaluates the comparison for each cell or row in the applied range. On Mac, the Conditional Formatting controls are also on the Home tab, although the arrangement may vary slightly by Excel version. Excel for the web offers conditional formatting too, but its interface can differ from the Windows desktop steps.
Text comparisons, capitalization, and data types
Ordinary Excel text comparisons with <> are not case-sensitive. If A2 contains North and B2 contains north, =A2<>B2 returns FALSE. Excel treats those strings as equal for this comparison even though their capitalization differs.
For a case-sensitive comparison, use EXACT, which returns TRUE only when the text matches exactly, including capitalization. With A2 containing North and B2 containing north, =NOT(EXACT(A2,B2)) returns TRUE because the strings differ in case. EXACT is designed for text comparisons, so use it when capitalization itself carries meaning, such as a code or identifier.
Also check that values that look alike are stored in compatible forms. A number entered as text, an actual number, a date stored as text, and a real date can behave differently in comparisons and criteria. If a result seems surprising, inspect the source cells and their formats, but remember that changing a number format does not necessarily convert the underlying value. Consistent data entry is usually more reliable than trying to compensate for mixed types in every comparison formula.
Common errors and troubleshooting
Most mistakes come from using the wrong characters or putting a criteria operator in the wrong form. In a normal worksheet comparison, write <> between the values. In a COUNTIF-style criteria argument, put the operator in quotation marks, such as "<>Paid". When the excluded value is in a cell, join the quoted operator to the reference with &.
- Using !=: Excel formulas use
<>, not!=, for not equal. - Unexpected blank results: Decide whether formula-generated empty strings, truly empty cells, and cells containing spaces should count as blank.
- Unexpected text matches: Regular text comparisons ignore capitalization; use EXACT when case matters.
- A formula returns an error: If either side of a comparison contains an error such as #N/A, the comparison can return that error instead of TRUE or FALSE. Fix the source error or handle it deliberately.
- Wrong conditional-formatting rows: Check that the formula references match the top row of the selected range and that dollar signs lock only the references that should stay fixed.
IFERROR can provide a fallback message when a comparison encounters an error. With A2 containing #N/A, =IFERROR(A2<>"Paid","Check source") returns Check source. Use this carefully: IFERROR handles many kinds of errors, so it can also hide problems that deserve investigation. A visible warning is often better than silently treating an error as an ordinary match or mismatch.
Frequently Asked Questions
What is the not-equal symbol in Excel?
It is <>, typed as a less-than sign followed by a greater-than sign. Use it between values or cell references in a formula.
How do I write “not equal to” in an IF formula?
Put the comparison inside IF’s logical test. For example, =IF(A2<>"Paid","Follow up","Complete") returns Follow up unless A2 contains Paid.
How do I count cells that are not equal to a value?
Use COUNTIF with a not-equal criteria, or COUNTIFS if you also need to exclude blanks. Join the quoted operator to a cell reference with & when the value to exclude is stored in a cell.
Does Excel’s not-equal test distinguish uppercase and lowercase?
No. Standard text comparisons are case-insensitive. Use EXACT inside NOT when a difference in capitalization should count as a mismatch.
Why does a cell that looks blank count as not blank?
It may contain spaces or a formula returning an empty string. A comparison with an empty string treats those cases differently from ISBLANK, which returns TRUE only for a genuinely empty cell.
Related
- Excel Data Modeling: How It Works and When to Use It
- Excel Data Modelling: Tables, Relationships and Pivots
- Excel Get Data From a Semantic Model: Connect and Analyze
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Google Sheets Cell Dropdown List: Setup and TipsTo create a cell dropdown list in Google Sheets, select the cell or range, choose Insert > Dropdown,…
- Enable Circular References in Excel: Step-by-StepTo enable circular references in Excel for Microsoft 365 on Windows, open the workbook, select File > Options…
- Excel Keyboard Shortcut to Hide a Row (and Unhide It)In Excel for Microsoft 365 on Windows, select a cell in the row—or select the whole row—and press…
- Create a Questionnaire Template in Word Step by StepTo create a questionnaire template in Microsoft Word, lay out your questions and response areas in a document,…
- VBE Editor in Windows: Name, Access, and UsesThe VBE editor in Windows is the Visual Basic Editor, commonly called the VBA Editor. It is the…
- How to Make Just One Page Landscape in Microsoft WordTo make just one page landscape in Microsoft Word, isolate it in its own section: insert a Next…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.