Confident CellsExcel practice Start free

If a cell contains text in Excel

Updated 26 November 2026 · 5 min read

To show "Refund" when a note in B2 mentions a refund anywhere in it, use =IF(ISNUMBER(SEARCH("refund",B2)),"Refund",""). SEARCH looks for the word inside the text, ISNUMBER turns "found it" into TRUE, and IF shows what you want. It works in every version of Excel, on Windows and Mac, and in Excel for the web.

The formulas at a glance

You wantFormulaNotes
A value if the cell contains a word=IF(ISNUMBER(SEARCH("refund",B2)),"Refund","")Capitals don't matter
The same, shorter=IF(COUNTIF(B2,"*refund*"),"Refund","")The * on both sides means "anything before or after"
Capitals must match too=IF(ISNUMBER(FIND("RF-",B2)),"Yes","")FIND cares about capitals; SEARCH doesn't
The word to look for is in a cell=ISNUMBER(SEARCH($E$1,A2))Lock the cell with $ before you copy down
Either of two words=IF(OR(ISNUMBER(SEARCH("refund",B2)),ISNUMBER(SEARCH("money back",B2))),"Refund","")Use AND when it must contain both
Any text at all, where a number doesn't count=IF(ISTEXT(B2),"Text","")For "is there any text in this cell?"
How many cells contain it=COUNTIF(B2:B11,"*refund*")No flag column needed

Each one is worked through below.

A worked example

A support team keeps a note of every call. You want a flag on every call that mentions a refund, wherever the word is and whatever the capitals.

SEARCH tells you where the word starts. In "Refund sent on Friday" it starts at the 1st character. In "Customer wants a refund", count the letters and spaces: "Customer wants a " is 17 characters, so refund starts at the 18th. When the word isn't there, SEARCH gives the error #VALUE!.

ABCD
1NoteSEARCHISNUMBERFlag
2Refund sent on Friday1TRUERefund
3Customer wants a refund18TRUERefund
4Delivery delayed again#VALUE!FALSE
The working-out in three steps. B2 holds =SEARCH("refund",A2), C2 holds =ISNUMBER(B2) and D2 holds =IF(C2,"Refund",""), all copied down. Column B gives a position or #VALUE!, column C turns that into TRUE or FALSE, and column D shows the flag.

A number means found, and the error means not found. ISNUMBER asks "is this a number?", which turns the answer into TRUE or FALSE. IF then shows "Refund" for TRUE and nothing for FALSE. Put the three steps together and you get one formula:

=IF(ISNUMBER(SEARCH("refund",B2)),"Refund","")

The value to return can be anything: a number such as 1, a word, or another cell, such as =IF(ISNUMBER(SEARCH("refund",B2)),C2,0) to bring back the amount only on refund rows.

Another way: COUNTIF with wildcards

The * wildcard stands for "any text, or none". So "*refund*" means refund with anything before it and anything after it. COUNTIF on a single cell gives 1 if it matches and 0 if not, and IF treats 1 as TRUE:

=IF(COUNTIF(B2,"*refund*"),"Refund","")

Both give the same answer. COUNTIF is shorter, and SEARCH is easier to build on, as the next sections show. Leave out the first * and COUNTIF only finds notes that start with refund.

Look for the word typed in a cell

Type the word into E1 and point the formula at it, so anyone can change what it looks for. Lock E1 with $ so it stays put when you copy the formula down (see locking a cell with $):

=ISNUMBER(SEARCH($E$1,A2))
ABCDE
1NoteFound?With COUNTIFLook fordelivery
2Delivery delayed againTRUEYes
3Refund sent on FridayFALSENo
4Changed delivery addressTRUEYes
5Left a voicemailFALSENo
E1 holds the word to look for. B2 holds =ISNUMBER(SEARCH($E$1,A2)) and C2 holds =IF(COUNTIF(A2,"*"&$E$1&"*"),"Yes","No"), both copied down.

On its own, without IF, the SEARCH version shows TRUE or FALSE, which is handy for filtering. With COUNTIF, join the wildcards on with &: "*"&$E$1&"*". Type another word in E1 and both columns change.

Any of several words, or both

To flag notes that mention a refund or money back, put two SEARCH checks inside OR. To flag only the notes that mention both a refund and the manager, use AND:

ABC
1NoteRefund or money backRefund and manager
2Refund agreed by managerFlagFlag
3Wants their money backFlag
4Refund sent on FridayFlag
5Asked for the manager
B2 holds =IF(OR(ISNUMBER(SEARCH("refund",A2)),ISNUMBER(SEARCH("money back",A2))),"Flag",""). C2 holds the same with AND and "manager". Both are copied down.

With OR, any one of the words is enough, so three of the four notes are flagged. With AND, the note must have both, so only the first one is.

Capitals that matter: FIND

FIND works like SEARCH but cares about capitals. That's what you want for codes, where "RF-" is a refund code and "rf-" isn't. For everyday words, SEARCH is safer:

ABC
1NoteSEARCHFIND
2Refund sent on FridayTRUEFALSE
3Customer wants a refundTRUETRUE
4REFUND agreed by managerTRUEFALSE
B2 holds =ISNUMBER(SEARCH("refund",A2)) and C2 holds =ISNUMBER(FIND("refund",A2)), both copied down. FIND misses Refund and REFUND.

To make the capitals the same in the notes themselves, see changing case.

If a cell has any text in it

Sometimes "contains text" means "has words in it, as opposed to a number or nothing". ISTEXT is TRUE for text and FALSE for numbers and empty cells. To test for anything at all, number or text, use A2<>"". Here the entries are in column A:

ABCD
1EntryISTEXTNot emptyFlag
2PaidTRUETRUEText
3125FALSETRUE
4FALSEFALSE
5TBCTRUETRUEText
B2 holds =ISTEXT(A2), C2 holds =A2<>"" and D2 holds =IF(ISTEXT(A2),"Text",""), all copied down. 125 is a number, so ISTEXT gives FALSE, though the cell isn't empty.

This is how to spot a "TBC" or "n/a" typed into a column of figures before it causes a #VALUE! error. A number stored as text counts as text here too, which is often exactly what you want to find.

Count them, or colour them

To count how many notes mention a refund, you don't need a flag column at all: =COUNTIF(B2:B11,"*refund*") (more in counting cells with text).

To colour the whole row instead, select the rows, then go to Home › Conditional Formatting › New Rule and choose Use a formula to determine which cells to format. On a Mac, in the New Formatting Rule box, set Style to Classic first, then choose that option. Type =ISNUMBER(SEARCH("refund",$B2)), with the $ before B so every cell on the row looks at the note. Conditional formatting with a formula has more.

Common mistakes

#VALUE! on the rows without the word

=IF(SEARCH("refund",B2),"Refund","") works for the notes that mention a refund, and gives #VALUE! for all the others, because SEARCH's error goes straight through IF. Wrap SEARCH in ISNUMBER.

Using = with the word

=IF(B2="refund","Refund","") is only TRUE when the whole cell says refund and nothing else. And =IF(B2="*refund*",…) doesn't work either: the = sign doesn't understand wildcards. Only functions such as COUNTIF, SUMIF, MATCH, VLOOKUP and XLOOKUP do.

Part of a longer word

SEARCH finds the letters anywhere, so looking for "ref" also finds "referral" and "preferred". Search for the whole word, or add spaces round it: " ref ".

Spaces you can't see

Searching for "refund " with a space misses "a refund" at the very end of a note. Take the space out of the word you search for. If the word is typed in a cell, tidy it inside the formula with TRIM: =ISNUMBER(SEARCH(TRIM($E$1),A2)).

Try it now

Your turn

In C2, show Refund next to every note that mentions a refund anywhere in it, whatever the capitals, and leave the cell empty otherwise. Your formula will be copied down to C11.

ABC
1CallNoteFlag
2C401Left a voicemail
3C402Refund sent on Friday
4C403Customer wants a refund for the lid
5C404Delivery delayed again
6C405REFUND agreed by manager
7C406Changed delivery address
8C407Asked about our refund policy
9C408Wrong size sent, swap arranged
10C409Part refund of £12.50 agreed
11C410Called back, no answer

Open this in Try a formula: the same sheet with the answer filled in, to change or share by link.

Part of Excel data cleaning practice: every lesson on the topic, with a project in Excel.

Where it works

SEARCH, FIND, ISNUMBER, ISTEXT and COUNTIF with wildcards work the same in every version of Excel, on Windows and Mac, and in Excel for the web.

Questions

How do I return a value if a cell contains certain text?

Use IF with ISNUMBER and SEARCH: =IF(ISNUMBER(SEARCH("refund",B2)),"Refund",""). SEARCH finds the word anywhere in B2 and gives its position, or an error if it isn't there. ISNUMBER turns that into TRUE or FALSE, and IF shows the first value for TRUE and the second for FALSE. Swap "Refund" for any word, number or cell you want back.

How do I check if a cell contains text in Excel?

It depends what you mean. To check for a particular word, use =ISNUMBER(SEARCH("word",B2)), which gives TRUE or FALSE. To check whether the cell holds any text at all, as opposed to a number or nothing, use =ISTEXT(B2). To check it isn't empty, whatever it holds, use =B2<>"". All three can go inside IF.

Is SEARCH or FIND better for checking text?

SEARCH, for most jobs. It ignores capitals, so it finds Refund, refund and REFUND alike, and it understands the wildcards * and ?. FIND only matches the exact capitals you type, which is useful for codes where capitals mean something, such as RF- for a refund. Both give a #VALUE! error when the text isn't there, so wrap either one in ISNUMBER.

Can I use a wildcard with IF in Excel?

Not with an equals sign: =IF(B2="*refund*",…) looks for the actual characters *refund*. Put the wildcard inside COUNTIF instead, which does understand it: =IF(COUNTIF(B2,"*refund*"),"Refund",""). COUNTIF gives 1 when the cell matches and 0 when it doesn't, and IF treats 1 as TRUE. SUMIF, MATCH, VLOOKUP and XLOOKUP understand wildcards too.