How to check if a cell contains specific text
✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)Return Yes/No (or anything else) depending on whether a cell contains a word or substring.
The formula
| App | Formula | Notes |
|---|---|---|
| Excel (desktop) | =IF(ISNUMBER(SEARCH("red",A2)),"Yes","No") | SEARCH is case-insensitive; use FIND for case-sensitive matching. |
| Google Sheets | =IF(ISNUMBER(SEARCH("red",A2)),"Yes","No") | Identical; REGEXMATCH(A2,"red") is a Sheets-only shortcut. |
| LibreOffice Calc | =IF(ISNUMBER(SEARCH("red",A2)),"Yes","No") | Identical. |
How it works
SEARCH returns the position of "red" inside the text (here 6) or a #VALUE! error when it's absent. ISNUMBER turns that into TRUE/FALSE, and IF maps it to your labels. You can't write =IF(A2="*red*",...) — wildcards don't work in a plain equals test, which is the usual reason this formula surprises people. To count or sum by contains instead, COUNTIF/SUMIF do accept wildcards: =COUNTIF(A:A,"*red*").
Verified, not just documented
We ran =IF(ISNUMBER(SEARCH("red",A2)),"Yes","No") in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned Yes — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned Yes for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.
Functions used
IF · ISNUMBER · SEARCH — see full Excel, Google Sheets & LibreOffice compatibility for each.
Related recipes
- How to check if a cell contains any word from a list
- How to average a range that contains errors
- How to compare two columns row by row
- How to concatenate cells that meet a condition (TEXTJOIN IF)
- How to convert Yes/No (or TRUE/FALSE) to 1 and 0