CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Microsoft Excel – Comparison Operators

Microsoft Excel provides Comparison Operators to compare the values of two operands. You can give the values directly or you can give the Cell references when you use these operators in Excel formulas.

Comparison Operators

Excel’s comparison operators are useful to compare the values in two operands. You can compare two values or the values in cell references. After the comparison, if there is no ERROR, always these operators return the logical value TRUE or FALSE.

Unlike Arithmetic Operators, you can not apply these operators on multiple operands; if you do so, it always returns the negation of the actual result. If you want to compare multiple values at a time, then you must use Logical Functions. I will try to explain them in another article.

Equality Operators

Equality operators are useful to verify the equality of the operands. Excel provides “= Operator – Equal sign” and “<> Operator – Not Equal sign” to check the equality of the operands. The equality operator verifies whether two values are equal; whereas the Not equality operator verifies whether two values are NOT equal. When dealing with these operators; you need to remember the below:

  • When comparing strings or text, it is always considered case-insensitive. That means Upper and Lowercase letters are considered as same. For example, the texts “APPLE” and “apple” are the same.
  • Unlike Arithmetic operators, we can use Comparison Operators on any type of data.
  • Data can not be converted to numbers when comparing text values. For example, “65” = 65 always returns FALSE; because “65” is the string and 65 is the numeric data type.
  • When you apply these operators on multiple values; always returns the negation of the result. For example, =5=5=5 always returns the negation of TRUE which is FALSE. In the same way, =5<>5<>5 always returns, the negation of FALSE which is TRUE. It evaluates like this; from =5=5=5; first, it verifies, =5=5 which returns TRUE then, =TRUE=5 which returns FALSE.
  • Also “TRUE” is a string or text; which is different than the Boolean value TRUE.

See the below table for more examples:

Comparison Operators
DataOperatorExampleCell ReferenceResult
5equal sign
(=)
=5=5=A3=A4TRUE
5=5=6.5=A3=A6FALSE
65=”A”=65=A10=A9FALSE
6.5=”65″=65=A9=A5FALSE
“APPLE”=”APPLE”=”apple”=A7=A8TRUE
“apple”=”A”=”B”=A10=A11FALSE
“65”=”10/9/2018″=”10/10/2018″=A12=A13FALSE
“A”=TRUE=FALSE=A14=A15FALSE
“B”=5=5=5=A3=A4=A3FALSE
43382=”TRUE”=TRUE=A16=A14FALSE
43383
=TRUE
=FALSE
=”TRUE”not equal sign
(<>)
=5<>5=A3<>A4FALSE
=5<>6.5=A3<>A6TRUE
=”A”<>65=A10<>A9TRUE
=”65″<>65=A9<>A5TRUE
=”APPLE”<>”apple”=A7<>A8FALSE
=”A”<>”B”=A10<>A11TRUE
=”10/9/2018″<>”10/10/2018″=A12<>A13TRUE
=TRUE<>FALSE=A14<>A15TRUE
=5<>5<>5=A3<>A4<>A3TRUE
=”TRUE”<>TRUE=A16<>A14TRUE

Note that, always the formula in Excel starts with the “=” sign. And also to assign a value to the Cell; we can use the “=” sign. For example, =78, which means, it assigns the value 78 to the Cell.

Greater than Operators

In Excel, we have “Greater than (>)” and “Greater than or equal to (>=)” operators to compare the two values and return whether the first value is Greater or Greater than equals to the second value.

When you use the “Greater than (>)” operator, it verifies whether the first value is greater than the second value. But the “Greater than or equal to (>=)” operator, compares two values; whether the first value is greater than or equal to the second value. Notice that, “>=” verifies also the equality of the two values.

See the below table for more examples:

Comparison Operators
DataOperatorExampleCell ReferenceResult
5greater than sign
(>)
=5>5=A3>A4FALSE
5=5>6.5=A3>A6FALSE
65=”A”>65=A10>A9TRUE
6.5=”65″>65=A9>A5TRUE
“APPLE”=”APPLE”>”apple”=A7>A8FALSE
“apple”=”A”>”B”=A10>A11FALSE
“65”=”10/9/2018″>”10/10/2018″=A12>A13FALSE
“A”=TRUE>FALSE=A14>A15TRUE
“B”=5>5>5=A3>A4>A3TRUE
43382=”TRUE”>TRUE=A16>A14FALSE
43383
TRUE
FALSE
“TRUE”greater than or equal to sign
(>=)
=5>=5=A3>=A4TRUE
=5>=6.5=A3>=A6FALSE
=”A”>=65=A10>=A9TRUE
=”65″>=65=A9>=A5TRUE
=”APPLE”>=”apple”=A7>=A8TRUE
=”A”>=”B”=A10>=A11FALSE
=”10/9/2018″>=”10/10/2018″=A12>=A13FALSE
=TRUE>=FALSE=A14>=A15TRUE
=5>=5>=5=A3>=A4>=A3TRUE
=”TRUE”>=TRUE=A16>=A14FALSE

Always these operators return the result either TRUE or FALSE.

Less than Operators

Like greater than operators, Excel provides Less than Operators; “Less than (<)” and “Less than or equal to (<=)” operators to compare the two values; whether the first value is lesser than or lesser than equal to the second value.

Here are the examples:

Comparison Operators
DataOperatorExampleCell ReferenceResult
5less than sign
(>)
=5<5=A3<A4FALSE
5=5<6.5=A3<A6TRUE
65=”A”<65=A10<A9FALSE
6.5=”65″<65=A9<A5FALSE
“APPLE”=”APPLE”<“apple”=A7<A8FALSE
“apple”=”A”<“B”=A10<A11TRUE
“65”=”10/9/2018″<“10/10/2018”=A12<A13TRUE
“A”=TRUE<FALSE=A14<A15FALSE
“B”=5<5<5=A3<A4<A3FALSE
43382=”TRUE”<TRUE=A16<A14TRUE
43383
TRUE
FALSE
“TRUE”less than or equal to sign
(>=)
=5<=5=A3<=A4TRUE
=5<=6.5=A3<=A6TRUE
=”A”<=65=A10<=A9FALSE
=”65″<=65=A9<=A5FALSE
=”APPLE”<=”apple”=A7<=A8TRUE
=”A”<=”B”=A10<=A11TRUE
=”10/9/2018″<=”10/10/2018″=A12<=A13TRUE
=TRUE<=FALSE=A14<=A15FALSE
=5<=5<=5=A3<=A4<=A3FALSE
=”TRUE”<=TRUE=A16<=A14TRUE

Observe that, when you compare text and numeric data; the text value considers higher than the numeric value. When you compare text and numeric values; it is good practice to convert them to either text or numeric data using VALUE or TEXT functions. I will try to explain these functions in the next Articles.

We will discuss more Excel functions/operators as we go.

🙂 Sahida

Microsoft Excel – Comparison Operators

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top