There are six comparison operators used in Excel. These operators are used to test for numerical equality - such as 7 = 7 - and inequalities - such as 7 < > 3 or 2 < 12.
Excel's Comparison Operators
The six operators are:
Equals ( = )
Less than ( < )
Less than or equal to ( < = )
Greater than ( > )
Greater than or equal to ( > = )
Not equal to ( < > )
Use in Conditional Statements
These operators are used in conditional statements, such as the IF function logical test argument to determine equality or difference between two values or operands.
The result of the logic test argument is only ever TRUE or FALSE.
If the condition being tested is TRUE, the action listed in the Value_if_true argument is carried out.
If the condition being tested is FALSE, the action listed in the Value_if_false argument is executed.
Use in Formulas
Conditional operators can also be used in a formula that compares the values in two cells in a worksheet. The result for this type of formula will only ever be either TRUE or FALSE.
For example, if cell A1 contains the number 23 and cell A2 contains the number 32, the formula =A2 > A1 would return a result of TRUE.
The formula =A1 > A2, on the other hand, would return a result of FALSE.
Use in Macros
Comparison operators are also used in conditional statements in Excel macros, especially in loops, where the result of the comparison decides whether execution should proceed.