In Excel, if you want to check if a cell value is not equal to another value, you can use the not equal operator “<>”. It returns TRUE if the value matches or FALSE if it doesn’t match. You can use it as a formula, or you can also use it with other functions like IF, OR, and AND.
In the following example, you have two values in cells A1 and A2 and you need to check if value 1 is not equal to value 2.
Using DOES NOT EQUALS Operator
- First, in cell B1, enter the equal operator.
- After that, refer to cell A1 where you have the first value.
- Next, enter the “<>” not equal operator.
- Now, refer to the second value that we have in cell A2.
- In the end, hit enter to get the value.
The moment you hit enter, it returns TRUE in the result. This is because both values are not equal. Now if you enter “Excel” in cell B1, the result that we have in cell A1 changes to FALSE. The reason because we have the same values in both cells.
Using DOES NOT EQUAL with OR – AND
As I said, you can use the not equals operator with other functions as well. Let’s try to use it with AND and OR functions.
With the OR function, you can test two conditions and it will return TRUE if any of the conditions or both conditions are the same. In the following example, we have two conditions to test. Comparing values from cells A1 and A2 and then from B1 and B2.
Now as we are using does not equal operator in both conditions, and in the first condition both values are not equal, so it returns TRUE. But after that in the second condition, both values are the same so the condition is FALSE.
But in the result, we have got TRUE, because as we have discussed, OR returns TRUE if only one condition is TRUE.
Next, use the same with the AND function. AND returns TRUE if all the specified conditions are the same, and FALSE even if one condition is FALSE from all.
In the above example, again we have the same values but when you use AND function it returns FALSE in the result as the second condition (B1<>B2) is not true, both of the values are the same.
Use DOES NOT EQUAL Operator with IF Function
You can also use the does not equal operator within the IF function.
- Enter the IF function in a cell where you want to have the result.
- After that, refer to cell A1 and then use the not equal operator and refer to cell A2.
- Next, use a value to get if the condition is TRUE.
- In the end, specify the value if the condition is FALSE.
The best thing about using the IF with the “does not equal” condition is that you can return a specific value that you get if the condition is TRUE or FALSE.