# How to check if a cell contains one of several words in Google Sheets

Join the words into one pattern with | and test it: =REGEXMATCH(A2,"(?i)"&TEXTJOIN("|",TRUE,$D$2:$D$4)).

**Google Sheets:** `=REGEXMATCH(A2,"(?i)"&TEXTJOIN("|",TRUE,$D$2:$D$4))`

**Excel:** In Excel 365 use REGEXTEST with 1 as the case argument: =REGEXTEST(A2,TEXTJOIN("|",TRUE,$D$2:$D$4),1). In any version, =SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$4,A2)))>0 does the same.

## Example

Sample data (row 1 is the header):

| A | B | C | D |
| --- | --- | --- | --- |
| Ticket subject | Escalate? |  | Keywords |
| Refund not received |  |  | refund |
| Change delivery address |  |  | cancel |
| Please CANCEL my order |  |  | broken |
| Login problem after update |  |  |  |
| Item arrived broken |  |  |  |
| Where is my parcel? |  |  |  |

Formula in B2, filled to B7: `=REGEXMATCH(A2,"(?i)"&TEXTJOIN("|",TRUE,$D$2:$D$4))`

Result: TRUE; FALSE; TRUE; FALSE; TRUE; FALSE

## How it works

TEXTJOIN builds the pattern `refund|cancel|broken`, where | means "or". The `(?i)` at the start makes the match ignore case, so "CANCEL" counts. Because the words come from cells, you can add a keyword without touching the formula.

## Other ways

- `=SUMPRODUCT(--ISNUMBER(SEARCH($D$2:$D$4,A2)))>0`: No regular expressions: SEARCH looks for each keyword and SUMPRODUCT counts the hits. It works in Excel too.

## Common mistakes

- Characters with a meaning in patterns, like . + ( ) ?, must be escaped with a backslash in the keyword list, or they match the wrong thing.
- An empty keyword cell inside the range would add an empty alternative that matches everything. TEXTJOIN with TRUE skips blanks, so keep that argument.
- Without `(?i)` the match is case-sensitive, so "Please CANCEL my order" wouldn't match "cancel" in the list.

## Questions

**How do I match whole words only?**

Add word boundaries: `=REGEXMATCH(A2,"(?i)\b("&TEXTJOIN("|",TRUE,$D$2:$D$4)&")\b")`.

**How do I return the word that matched?**

Use REGEXEXTRACT with the same pattern: `=REGEXEXTRACT(A2,"(?i)"&TEXTJOIN("|",TRUE,$D$2:$D$4))`.

**How do I check a whole column with one formula?**

Wrap it in ARRAYFORMULA: `=ARRAYFORMULA(IF(A2:A7="","",REGEXMATCH(A2:A7,"(?i)"&TEXTJOIN("|",TRUE,$D$2:$D$4))))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/check-for-one-of-several-words-in-google-sheets
