Excel beginner

How to Return a Value if a Cell Contains Specific Text in Excel

Struggling to check if a cell contains certain text? Use the IF function combined with SEARCH to easily return desired values.

Formula Genius can generate a draft from a plain-English prompt. Supported formulas can be checked with sample cases; review the coverage on the result.

The formula

Prompt

"Return a value if a cell contains a specific word or partial text, using IF combined with SEARCH or FIND"

Excel
=IF(ISNUMBER(SEARCH("text", A1)), "Value if true", "Value if false")

This formula checks if a specified text exists within a cell and returns one value if true and another if false.

Step-by-step breakdown

  1. SEARCH function looks for the specified text within the target cell.
  2. ISNUMBER checks if the SEARCH function returns a valid position (number).
  3. IF evaluates the result of ISNUMBER to determine which value to return.
  4. Specify the text you are searching for and the cell reference.

Edge cases & warnings

  • The search text is case-sensitive when using FIND instead of SEARCH.
  • The formula returns an error if the cell is empty.
  • If the search text is not found, the formula returns the 'Value if false'.

Examples

Prompt

"A1 contains 'Hello World', search for 'World'"

Excel
'Value if true'
Prompt

"A1 contains 'Goodbye', search for 'Hello'"

Excel
'Value if false'

Frequently asked questions

Can I use this formula for partial text?

Yes, the SEARCH function allows for partial matches.

What happens if the text is not found?

The formula will return the specified 'Value if false'.

Is this formula case-sensitive?

No, SEARCH is not case-sensitive, but FIND is.

Can't find what you need?

Describe a formula in plain English. Formula Genius drafts and explains it, and can check supported formulas on sample cases.