ISNUMBER and SEARCH: Check if a Cell Contains Text
By ExcelReady TeamUpdated 7 min read
The short answer
Use =ISNUMBER(SEARCH("refund",B2)). SEARCH looks for the text inside B2 and returns its position as a number, or a #VALUE! error if it isn't there. ISNUMBER turns that into TRUE or FALSE. Wrap it in IF to show your own labels, and swap SEARCH for FIND when capitals must match exactly.
Key takeaways
- =ISNUMBER(SEARCH("text",cell)) returns TRUE if the cell contains the text anywhere, and FALSE if not.
- SEARCH ignores capitals; FIND is case-sensitive. Both work inside ISNUMBER.
- Wrap the test in IF to return labels: =IF(ISNUMBER(SEARCH("refund",B2)),"Refund","Other").
- An empty search text matches every cell, because SEARCH("",B2) returns 1.
- The same test works in conditional formatting, FILTER and SUMPRODUCT.
On this page+
- How ISNUMBER and SEARCH work together
- The sample data
- How to return your own labels with IF
- How to make the check case-sensitive
- How to check that a cell does not contain text
- How to check for several words
- How to use the test in FILTER, counts and highlighting
- Common problems and how to fix them
- Practise it
ISNUMBER with SEARCH is the standard Excel way to check if a cell contains some text: =ISNUMBER(SEARCH("refund",B2)) returns TRUE when "refund" appears anywhere in B2 and FALSE when it doesn't. It works in every Excel version and ignores capitals. This guide explains why the two functions work together, then shows the test inside IF, with several words, case-sensitive, and in FILTER and counts.
How ISNUMBER and SEARCH work together#
SEARCH finds text and returns a position; ISNUMBER turns that position into TRUE or FALSE. On their own, each function is only half the answer.
SEARCH looks for one piece of text inside another:
=SEARCH(find_text, within_text, [start_num])If it finds the text, it returns the position of the first character. If not, it returns a #VALUE! error. ISNUMBER checks whether a value is a number and returns TRUE or FALSE. It never returns an error itself.
Put together, the two possible SEARCH results become a clean answer:
| B2 | SEARCH("refund",B2) | ISNUMBER(SEARCH("refund",B2)) |
|---|---|---|
| Refund request for order 4471 | 1 | TRUE |
| Login problem | #VALUE! | FALSE |
| Where is my refund? | 13 | TRUE |
| Return and REFUND please | 12 | TRUE |
The SEARCH function guide and the ISNUMBER function guide cover each function's arguments.
The sample data#
The examples below use this list of support tickets in A1:B7:
| A | B | |
|---|---|---|
| 1 | Ticket | Subject |
| 2 | T-201 | Refund request for order 4471 |
| 3 | T-202 | Login problem |
| 4 | T-203 | Where is my refund? |
| 5 | T-204 | Change delivery address |
| 6 | T-205 | Return and REFUND please |
| 7 | T-206 | Invoice copy needed |
Three subjects mention a refund (rows 2, 4 and 6), with different capitals and in different places.
How to return your own labels with IF#
TRUE and FALSE are fine for checking, but reports usually need words. Wrap the test in IF:
=IF(ISNUMBER(SEARCH("refund",B2)),"Refund","Other")Fill it down (Windows: Ctrl+D; Mac: ⌘D). Rows 2, 4 and 6 show Refund; the rest show Other.
You don't need =TRUE inside the IF. ISNUMBER already returns TRUE or FALSE, which is exactly what IF's first argument expects. To read the search word from a cell instead, such as E1, write SEARCH($E$1,B2). Lock it with $ so it stays put as you fill down.
How to make the check case-sensitive#
Use FIND instead of SEARCH. FIND works the same way, but "Refund" and "REFUND" are different to it.
=ISNUMBER(FIND("Refund",B2))Only row 2 returns TRUE. Row 4 has "refund" in lower case and row 6 has "REFUND" in capitals, so FIND returns #VALUE! and ISNUMBER returns FALSE. The comparison of FIND vs SEARCH covers the other differences, such as wildcards.
How to check that a cell does not contain text#
Wrap the test in NOT to flip TRUE and FALSE. This returns TRUE for the subjects that don't mention a refund:
=NOT(ISNUMBER(SEARCH("refund",B2)))Rows 3, 5 and 7 return TRUE. You may also see =ISERROR(SEARCH("refund",B2)), which gives the same result, because SEARCH returns an error exactly when the text is missing. Either works; the NOT version reads more clearly next to the "contains" formulas. Use it in IF to label the rest, or in FILTER to list the tickets that are not refunds.
How to check for several words#
Join tests with OR when any of the words is enough, and with AND when all must appear.
=OR(ISNUMBER(SEARCH("refund",B2)),ISNUMBER(SEARCH("return",B2)))This is TRUE for rows 2, 4 and 6. Row 6 contains both words, which still counts once.
=AND(ISNUMBER(SEARCH("return",B2)),ISNUMBER(SEARCH("refund",B2)))This is TRUE only for row 6, the one subject that mentions both.
For a longer list of words, an array constant keeps the formula short:
=SUMPRODUCT(--ISNUMBER(SEARCH({"refund","return","cancel"},B2)))>0SEARCH checks each word, ISNUMBER gives TRUE or FALSE for each, -- turns those into 1s and 0s, and SUMPRODUCT adds them. If the total is above 0, at least one word was found.
How to use the test in FILTER, counts and highlighting#
Because ISNUMBER(SEARCH()) returns TRUE or FALSE, it slots into any tool that needs a condition.
Count matching cells. This returns 3:
=SUMPRODUCT(--ISNUMBER(SEARCH("refund",B2:B7)))=COUNTIF(B2:B7,"*refund*") gives the same count with wildcards, but the SEARCH version can be made case-sensitive by swapping in FIND.
Filter matching rows. In Excel 2021 or Microsoft 365:
=FILTER(A2:B7,ISNUMBER(SEARCH("refund",B2:B7)))This spills the three refund tickets into a new list. The guide to filtering rows that contain text builds a search box with this pattern.
Highlight matching cells. Use the same test as a conditional formatting rule, as shown in how to highlight cells that contain specific text.
Common problems and how to fix them#
Most surprises with ISNUMBER SEARCH come from what SEARCH matches, not from ISNUMBER.
- Every row returns TRUE. The search text is empty, often because it points at a blank cell.
SEARCH("",B2)returns 1. Guard it:=AND($E$1<>"",ISNUMBER(SEARCH($E$1,B2))). A cell holding""from a formula counts as empty text here too; see ISBLANK vs an empty string. - Partial words match. SEARCH finds text anywhere, so "art" matches "start" and "party". Search for
" art "with spaces, or add a space to both sides of the cell:SEARCH(" art "," "&B2&" "). - Wildcards behave oddly. In SEARCH,
?and*are wildcards. To find a real question mark, put a tilde before it:SEARCH("~?",B2). - Numbers in the cell. SEARCH treats numbers as text, so
SEARCH("44",B2)finds "4471". That is usually what you want, but be careful with short numbers. - Hidden spaces or line breaks. A word split by a line break may not match. Clean the text first with TRIM and CLEAN.
For more text-finding tricks, see how to find text with FIND and SEARCH.
Practise it#
Try the exercise on this page: build the IF, ISNUMBER and SEARCH formula from the inside out. Then practise FIND and SEARCH in a live spreadsheet to locate text and pull out parts of it, and practise IS functions and SWITCH to test values with ISNUMBER, ISTEXT and ISBLANK. Each lesson checks your formula instantly.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Label each support ticket. In C2, return Refund if the subject in B2 contains the word refund, otherwise Other. Use IF, ISNUMBER and SEARCH.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Type | |||
| 2 | Refund request for order 4471 | |||
| 3 | Login problem | |||
| 4 | Where is my refund? | |||
| 5 | Change delivery address | |||
| 6 | Return and REFUND please | |||
| 7 | Invoice copy needed | |||
| 8 | ||||
| 9 | ||||
| 10 |
Tip: Build it from the inside: SEARCH("refund",B2), then ISNUMBER(...), then IF(..., "Refund", "Other").
Practise this in a lesson
Frequently asked questions
How do I check if a cell contains specific text in Excel?
Use =ISNUMBER(SEARCH("text",A2)). It returns TRUE if the text appears anywhere in A2 and FALSE if it doesn't. SEARCH ignores capitals.
Why do you need ISNUMBER with SEARCH?
SEARCH returns a position number when it finds the text and a #VALUE! error when it doesn't. ISNUMBER turns those two outcomes into a clean TRUE or FALSE that IF, FILTER and conditional formatting can use.
How do I make ISNUMBER SEARCH case-sensitive?
Replace SEARCH with FIND: =ISNUMBER(FIND("Refund",A2)). FIND only matches the exact capitals, so refund and REFUND would return FALSE.
How do I check if a cell contains one of several words?
Join two tests with OR: =OR(ISNUMBER(SEARCH("refund",A2)),ISNUMBER(SEARCH("return",A2))). It returns TRUE if either word appears.
Why does ISNUMBER SEARCH return TRUE for every cell?
The search text is probably empty, for example a reference to a blank cell. SEARCH("",A2) returns 1, which is a number. Add a check such as AND(G1<>"",ISNUMBER(SEARCH(G1,A2))).