Excel Lessons

Excel comparison operators: =, <>, >, <, >= and <=

Every comparison in Excel returns TRUE or FALSE. The six operators, how they compare text, numbers and dates, and why "10" and 10 are not equal.

Published . 5 min read.

By Ali, Founder, Excel Lessons

Excel has 6 comparison operators: =, <>, >, <, >= and <=. Each one compares two values and returns TRUE or FALSE. Every IF, COUNTIF and FILTER test is built on one of them.

A warehouse prints a pick list each morning. It shows how many items each order needs, how many were picked, and the date it must ship. Here it is in A1 to E6.

Row A B C D E
1 OrderOrderedPickedShip byZone
2 510112125 Apr 2027North
3 5102857 Apr 2027south
4 510320208 Apr 2027NORTH
5 5104605 Apr 2027East
6 510515169 Apr 2027North

The six operators

SignMeansExampleResult
=equal to=C2=B2TRUE
<>not equal to=C5<>B5TRUE
>greater than=C6>B6TRUE
<less than=C3<B3TRUE
>=greater than or equal to=B2>=12TRUE
<=less than or equal to=C6<=B6FALSE

Three of the signs are two characters: <>, >= and <=. In >= and <=, the equals sign always comes second.

A comparison is a whole formula on its own. =C3<B3 asks: was order 5102 picked short? It returns TRUE, because 5 is less than 8.

The edge: > or >=

Most wrong flags come from this choice. Say an order of 12 or more needs a pallet.

=B2>=12 gives TRUE. Order 5101 needs a pallet.

=B2>12 gives FALSE. Greater than does not include equal, so 12 itself fails.

Read the rule again before you pick the sign. "12 or more" is >=. "More than 12" is >.

Comparing text

Text uses the same signs. Two things surprise people.

Capitals do not matter. =E4="north" gives TRUE, although E4 holds NORTH. Usually that helps. When capitals matter, use EXACT. =EXACT(E4,"North") gives FALSE.

Text is compared letter by letter. ="apple"<"Banana" gives TRUE, because a comes before b. But ="Zone 10"<"Zone 9" also gives TRUE. Excel compares the 1 with the 9 and stops. It does not read 10 as a number inside text.

Why "10" and 10 are not equal

A courier sends back its own list of order numbers. They arrive as text. Say G2 holds 5101 as text, and A2 holds 5101 as a number.

=A2=G2 gives FALSE. The two cells look the same, but one is a number and one is text.

="10"=10 gives FALSE for the same reason.

Here is the rule. When a comparison meets a number and some text, Excel does not convert either one. It treats all text as larger than all numbers. So ="10">10 gives TRUE. And =G2>9999 gives TRUE, although 5101 is smaller.

To compare them, turn one side into the same kind as the other. Both of these give TRUE:

  • =A2=VALUE(G2) turns the text into a number first.
  • =A2&""=G2 turns the number into text first.

The better fix is to clean the column once. The numbers stored as text article shows how.

Comparing dates

A date is a number, so the signs work on dates too. The trap is how you write the date inside the formula.

=D2<=DATE(2027,4,6) gives TRUE. Order 5101 ships on or before 6 April.

=D6>"2027-04-06" gives FALSE, but 9 April is later than 6 April. The date in quote marks is text. Text is larger than every number, and a date is a number.

So never put a date in quote marks after a comparison sign. Use DATE, or point at a cell that holds the date.

TRUE and FALSE are numbers too

Underneath, TRUE is 1 and FALSE is 0. =TRUE+TRUE gives 2. That is how you count the rows where a comparison is TRUE.

=SUMPRODUCT((C2:C6<B2:B6)*1) gives 2. Two orders were picked short, 5102 and 5104. The *1 turns each TRUE into 1 and each FALSE into 0.

Inside COUNTIF, the sign goes in quote marks

COUNTIF and SUMIF take the test as text. So the sign goes inside quote marks.

  • =COUNTIF(C2:C6,">=12") gives 3.
  • =COUNTIF(E2:E6,"<>North") gives 2. Capitals are ignored here too, so NORTH is not counted.
  • =COUNTIF(D2:D6,"<="&DATE(2027,4,6)) gives 2. The & joins the sign to the date.

Questions people ask

How do I show a word instead of TRUE?

Put the comparison inside IF. =IF(C3<B3,"Short","OK") gives Short. The IF exercises have ten more.

How do I test two things at once?

Use AND or OR around two comparisons. The AND, OR and NOT article covers both.

Does an empty cell equal 0?

Yes. If H2 is empty, =H2=0 gives TRUE. So does =H2="". An empty cell counts as 0 and as empty text.

Where can I practise comparisons?

In the two lessons below. Each lesson is a real sheet you type into, and each answer is checked when you press Enter.

Related articles