Comparison Operators in Excel — With Examples (=, <>, >, <, >=, <=)
Learn Excel comparison operators: equal, not equal, greater than, less than, and between two numbers, in IF, COUNTIF and SUMIF.
Read Guide →You want to flag the orders whose notes mention “Rush” — not the orders whose note is “Rush”, but any note where the word appears. The obvious formula does not work: =IF(F2="Rush","Priority","Standard") asks whether the cell IS “Rush”, not whether the word appears somewhere inside it. The formula that works is =IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard") — and it returns “Priority” on three of the ten orders in this guide. This page runs that formula and the three other ways on the same ten-order table, so you can check every answer yourself — SEARCH with ISNUMBER, FIND for case, COUNTIF with wildcards, and the multi-word version — plus the traps: the #VALUE! error, the empty search box, and the word hiding inside a longer word.
Quick takeaway: SEARCH returns a position or an error — ISNUMBER turns that into Yes or No.
=IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard") → “Priority” on the three Rush orders, “Standard” on the rest.=IF(COUNTIF(F2,"*Rush*")>0,"Priority","Standard") → the same answer in fewer functions.=ISNUMBER(FIND("rush",F2)) is FALSE everywhere here.
Every example below uses the same ten orders. Only the Notes column matters here — the Sales column is used for the SUMIF at the end.
| Excel row | A Rep | B Region | C Sales | F Notes |
|---|---|---|---|---|
| 2 | Alex | East | 1200 | Rush |
| 3 | Priya | West | 850 | (blank) |
| 4 | Jordan | east | 2400 | Gift wrap |
| 5 | Sam | North | 450 | Call first |
| 6 | Alex | West | 1750 | (blank) |
| 7 | Taylor | East | 600 | Rush |
| 8 | Priya | East | 900 | (blank) |
| 9 | Jordan | South | 1100 | Delivery |
| 10 | Sam | West | 300 | (blank) |
| 11 | Alex | North | 1500 | Rush |
=IF(F2="Rush","Priority","Standard")
That test asks whether the cell IS “Rush”. On this table it happens to give the right answer — the three Rush notes are exactly “Rush” — but it fails the moment the note says anything more, like “Rush delivery” or “Please rush this order”. The cell is not the word. The word is inside the cell. You need a function that looks inside.
This is the combination to reach for by default. It ignores case, and it’s the only method here that handles the whole column with a single formula.
=ISNUMBER(SEARCH("Rush",F2:F11))
Here is what happens, row by row. SEARCH looks for “Rush” inside each note. When it finds the word, it returns the position it starts at, so a hit is always a number. When it doesn’t find the word, SEARCH returns a #VALUE! error instead. So the whole test comes down to one thing: did SEARCH hand back a number or not? That’s what ISNUMBER answers — it turns any number into TRUE and anything else, error included, into FALSE.
| Excel row | F Notes | SEARCH(“Rush”, F2) | ISNUMBER(…) |
|---|---|---|---|
| 2 | Rush | 1 | TRUE |
| 3 | (blank) | #VALUE! | FALSE |
| 4 | Gift wrap | #VALUE! | FALSE |
| 5 | Call first | #VALUE! | FALSE |
| 6 | (blank) | #VALUE! | FALSE |
| 7 | Rush | 1 | TRUE |
| 8 | (blank) | #VALUE! | FALSE |
| 9 | Delivery | #VALUE! | FALSE |
| 10 | (blank) | #VALUE! | FALSE |
| 11 | Rush | 1 | TRUE |
TRUE on rows 2, 7 and 11. FALSE on every other row, including the four blank notes — a blank note has nothing to find, so SEARCH errors and ISNUMBER says FALSE. In Excel 365 you can feed the formula the whole range F2:F11 and it spills down the column on its own, so you write it once and you’re done. On older Excel, write it for one cell and fill down.
TRUE and FALSE are fine, but you’ll usually want your own labels. Wrap the whole thing in IF and say what each outcome should return:
=IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard")
That returns “Priority” on rows 2, 7 and 11, and “Standard” on the other seven. And the positions tell you more than Yes or No: SEARCH("wrap", F4) returns 6, because “wrap” starts at the sixth character of “Gift wrap” — G is 1, i is 2, f is 3, t is 4, the space is 5, w is 6. SEARCH("gift", F4) returns 1. SEARCH("call", F5) returns 1. SEARCH("delivery", F9) returns 1.
| What you want | Formula | Result |
|---|---|---|
| Notes mention Rush | =IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard") | Priority on rows 2, 7, 11 |
| Notes mention gift | =IF(ISNUMBER(SEARCH("gift",F2)),"Yes","No") | Yes on row 4 only |
| Notes mention call | =IF(ISNUMBER(SEARCH("call",F2)),"Yes","No") | Yes on row 5 only |
| Notes mention delivery | =IF(ISNUMBER(SEARCH("delivery",F2)),"Yes","No") | Yes on row 9 only |
| Notes mention xyz | =IF(ISNUMBER(SEARCH("xyz",F2)),"Yes","No") | No on all ten rows |
Read the rows. “gift” matches “Gift wrap” — SEARCH ignores case, so the lowercase search term finds the capital G. “xyz” matches nothing, so every row is No.
Here’s another way to do this. If you already think in COUNTIF, this one reads more naturally than nesting two functions.
=IF(COUNTIF(F2,"*Rush*")>0,"Priority","Standard")
You get “Priority” on rows 2, 7 and 11 — the same answer Method 1 gave you. The asterisks are wildcards: an asterisk stands for any number of characters, so "*Rush*" means “anything, then Rush, then anything”. COUNTIF counts the cells that match the pattern — 1 for a hit, 0 for a miss — and >0 turns that into TRUE or FALSE. For a single keyword, COUNTIF with wildcards does the same job in fewer functions. It cannot do the position, and it cannot do two keywords in one formula — for those, use Method 1 or Method 4.
| What you want | Formula | Result |
|---|---|---|
| Count the Rush notes | =COUNTIF(F2:F11,"*Rush*") | 3 |
| Sum the Rush sales | =SUMIF(F2:F11,"*Rush*",C2:C11) | 3300 |
| Count the gift notes | =COUNTIF(F2:F11,"*gift*") | 1 |
The Rush sales are 1200 + 600 + 1500 = 3300 — the three Rush orders, rows 2, 7 and 11. The wildcard is the same * you already know from the COUNTIF formula and SUMIF formula guides.
SEARCH ignores case. FIND does not — swapping one for the other in the same formula is the only change needed to make the test case-sensitive.
| Formula | Result |
|---|---|
=ISNUMBER(SEARCH("rush",F2)) | TRUE on rows 2, 7, 11 — lowercase “rush” finds capital “Rush” |
=ISNUMBER(FIND("rush",F2)) | FALSE on all ten rows — there is no lowercase “rush” anywhere |
=ISNUMBER(FIND("Rush",F2)) | TRUE on rows 2, 7, 11 — the capital R matches |
Which one you want depends on the data. For words like “rush”, “urgent” or “refund”, SEARCH is what you want — a customer typing “RUSH” means the same thing. For currency codes, ticker symbols and part numbers, where USD and usd are not the same thing, use FIND.
For several keywords at once, an array constant inside SEARCH wrapped in SUMPRODUCT scales better than a stack of nested IFs:
=SUMPRODUCT(--ISNUMBER(SEARCH({"Rush","Gift"},F2)))>0
That returns TRUE on rows 2, 4, 7 and 11 — the three Rush orders plus the Gift wrap order. The array {"Rush","Gift"} runs SEARCH twice, once per word; ISNUMBER turns the two results into TRUE/FALSE; the -- turns TRUE into 1 and FALSE into 0; SUMPRODUCT adds them; and >0 is TRUE if either word was found. Add a third word by adding it to the array — no extra IFs.
| Mistake | What happens | Fix |
|---|---|---|
You used =IF(F2="Rush",...) | Only exact “Rush” cells match — “Rush delivery” is missed | Use SEARCH inside the IF |
| You left out ISNUMBER | =IF(SEARCH("Rush",F2),...) fills the column with #VALUE! on every non-matching row | Wrap SEARCH in ISNUMBER |
| You searched for the word inside a longer word | SEARCH(“rush”) also matches “Brush” — position 2 | Search for ” rush ” with spaces, or check the whole word |
| You used ” rush ” with spaces on a bare word | SEARCH(” rush “, “Rush”) is #VALUE! — there is no space at the edges | The space trick only works mid-cell; for a bare word, test the cell itself too |
| You cleared the search box | An empty search term matches at position 1 on every row — all TRUE | Guard it: =IF($H$2="","",IF(ISNUMBER(SEARCH($H$2,F2)),"Match","No match")) |
You put a ? or * in the search term | SEARCH treats them as wildcards, not letters | Prefix with a tilde: ~? or ~* |
| You expected it to work on numbers | SEARCH on a number cell works on its displayed text | Convert first with TEXT, or test the number directly |
The empty-search-box trap deserves the emphasis. An empty find_text matches at position 1, so a blank keyword cell reports found on every row — including the blank notes. If the search term lives in a cell the user can clear, wrap the formula in the guard above and the result stays blank until they type something.
How do I check if a cell contains specific text in Excel? =IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard") — SEARCH finds the word and returns its position, or #VALUE! if it is not there; ISNUMBER turns that into TRUE or FALSE; IF turns that into your labels.
Why does my formula show #VALUE! instead of No? Because you left out ISNUMBER. SEARCH returns #VALUE! when the text is not found, and IF on its own cannot turn an error into FALSE. Wrap SEARCH in ISNUMBER.
Does it care about capital letters? SEARCH does not — “rush” finds “Rush”. FIND does — use FIND when the case matters.
How do I check for two words at once? =SUMPRODUCT(--ISNUMBER(SEARCH({"Rush","Gift"},F2)))>0 — TRUE on rows 2, 4, 7 and 11 in this guide.
How do I count or sum only the rows that contain a word? =COUNTIF(F2:F11,"*Rush*") gives 3, and =SUMIF(F2:F11,"*Rush*",C2:C11) gives 3300 on this table.
Is there a CONTAINS function in Excel? No. This pattern is the CONTAINS function — and it works in every version of Excel, on Mac, on the web, and in Google Sheets. Nothing here needs Microsoft 365.
How do I return a value from another column when the cell contains text? Put the return in the IF: =IF(ISNUMBER(SEARCH("Rush",F2)),C2,"") returns the sales for the Rush rows and blank for the rest. For a lookup by two columns instead of one word, see the XLOOKUP multiple criteria guide.
That is the Excel formula for if a cell contains specific text: =IF(ISNUMBER(SEARCH("Rush",F2)),"Priority","Standard") — SEARCH looks inside the cell and returns the position or an error, ISNUMBER turns that into TRUE or FALSE, and IF turns that into your labels — and on the ten-order table in this guide it answers every question: Rush is on rows 2, 7 and 11, gift is on row 4, call is on row 5, delivery is on row 9, and xyz is on none of them. Remember the two things that catch everyone once: the obvious =IF(F2="Rush",...) only matches a cell that IS the word, not a cell that contains it — and SEARCH without ISNUMBER fills the column with #VALUE! on every row that does not match. And remember the two choices that change the answer: SEARCH ignores case and FIND does not, and SEARCH matches inside longer words, so “rush” also finds “Brush” unless you test for the whole word. From here, the next functions worth learning are the ones this one sits next to — the IF formula itself, for the nesting and the IFS version, and the COUNTIF formula for the wildcard counting and summing — and the full learning order for the whole site is on the Excel Formulas hub and the Logical & Conditional category page.
Learn Excel comparison operators: equal, not equal, greater than, less than, and between two numbers, in IF, COUNTIF and SUMIF.
Read Guide →Learn how to shade every other row in Excel: the MOD formula, banded table rows, odd rows, every third row and filters.
Read Guide →Learn how to highlight an entire row in Excel based on a cell value: the locked-column formula, text, numbers, dates and mistakes.
Read Guide →