Using the "does not equal" operator in Excel
If you're familiar with logical functions in Excel, you've probably used
But there are some situations in which you may need to figure out whether two values are not equal to one another. This is possible using the
The "does not equal" operator
Excel's "does not equal" operator is simple: a pair of brackets pointing away from each other, like so: "<>". Whenever Excel sees this symbol in your formulas, it will assess whether the two statements on opposite sides of these brackets are equal to one another. If they are not equal, it will output
Let's take a look at the "does not equal" operator in action to see how we can use it in a simple formula:
=6 <>8
Output:TRUE
The above formula outputs
=45 <>45
Output:FALSE
This formula outputs
Of course, "<>" doesn't have to be used on numbers. It can also be used on strings of text. Can you tell why the following formulas output the given results?
="Boston" <>"San Francisco"
Output:TRUE
="New York" <>"New York"
Output:FALSE
=RIGHT ("Boston, MA" ,2 )<>"MA"
Output:FALSE
Hint: For the last example above, you'll have to read up on how the
Combining <> with IF statements
The "does not equal" operator is useful on its own, but it becomes most powerful when combined with an
The spreadsheet above shows a list of SnackWorld's office locations around the country. The company's headquarters is in New York, and all of the other offices are local. A SnackWorld manager wants to add a column to the spreadsheet that dynamically outputs whether a given office is the company headquarters or a local office.
To do so, we could use the following formula:
=IF (B3 <>"New York" ,"Local office" ,"Headquarters" )
Output:"Local office"
Note that this formula outputs
Note that the above formula could be rewritten as follows, using the equals operator (=) but switching the order of the
=IF (B3 ="New York" ,"Headquarters" ,"Local office" )
Output:"Local office"
Is there any advantage to using the "<>" operator instead of the equals sign? Definitely. When you're using
Other logical operators
If you found this article useful, consider taking a look at our full article on logical operators. We'll teach you how to use the full range of logical operators, including "greater than" and "less than", in your formulas.
Save an hour of work a day with these 5 advanced Excel tricks
Work smarter, not harder. Sign up for our 5-day mini-course to receive must-learn lessons on getting Excel to do your work for you.
- How to create beautiful table formatting instantly...
- Why to rethink the way you do VLOOKUPs...
- Plus, we'll reveal why you shouldn't use PivotTables and what to use instead...