Function Problems

Return a Value When an Excel Cell Contains Any Word From a List

Steven ParkerSteven Parker Nov 12, 2026 868 views

Question details

The user needs to check whether a text cell contains any word from a separate list and return "Groceries" when a match is found.

Return a Value When an Excel Cell Contains Any Word From a List
Product
Microsoft Excel 2013
Device & OS
not provided
Scenario
Text is entered in cell A2, while the words to search for are listed in cells D2:D4.
Observed behavior
The desired result is "Groceries" when A2 contains at least one listed word; otherwise, the formula should return "Nil".
Before you start

Place the text to evaluate in A2 and keep each search word in a separate cell in D2:D4. Make sure the list does not include unintended blank cells or partial terms that could produce unwanted matches.

Solution 1Recommended

Use an array formula to test every word in the Excel list

Use this method in Excel 2013 and other Excel versions that require legacy array formulas for this type of multi-item text check.

The COUNTIF portion tests A2 against each wildcard search criterion created from D2:D4. The OR function returns TRUE when any item in the list is found.

1
Enter the formula in the result cell

Select the cell where you want the result, such as B2, and enter: =IF(OR(COUNTIF(A2,"*"&$D$2:$D$4&"*")),"Groceries","Nil")

2
Confirm it as an array formula

Instead of pressing Enter alone, press Ctrl+Shift+Enter. Excel adds curly braces around the formula in the formula bar to indicate that it is an array formula.

3
Check the returned result

Type text containing one of the words in D2:D4 into A2. The result cell returns "Groceries" when a match exists and "Nil" when no listed word is found.

Use an array formula to test every word in the Excel list
Wildcard matching: The asterisks (*) search for the listed text anywhere within A2. For example, a list item of "apple" also matches "apples" because it is a partial-text match.
Work with formulas in WPS Spreadsheets

Check a WPS Spreadsheet Cell for Any Word in a List

WPS Spreadsheets lets you build the same text-matching formula to classify entries such as grocery items. Open an Excel workbook, place your text and word list in the appropriate cells, then use a compatible COUNTIF-based formula to return a custom value when any list item is found.

  1. 1. Open the workbook in WPS Spreadsheets: Launch WPS Office, select Spreadsheets, and open your .xlsx or .xls file.
  2. 2. Set up the text and word list: Enter the text to check in A2 and place each search word in cells D2:D4.
  3. 3. Enter the matching formula: Select B2 and enter =IF(SUMPRODUCT(COUNTIF(A2,"*"&$D$2:$D$4&"*"))>0,"Groceries","Nil").
  4. 4. Fill the formula for additional rows: Select B2 and drag the fill handle downward to apply the same word-list check to other text cells.
Create text classification formulas with COUNTIF, IF, OR, and SUMPRODUCT.Open and edit Microsoft Excel .xlsx and .xls workbooks with formula compatibility.Use a familiar spreadsheet interface for cells, formulas, and ranges.Apply the formula down a column to categorize multiple text entries quickly.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Excel require Ctrl+Shift+Enter for this formula?

In legacy Excel versions, COUNTIF must evaluate multiple criteria from D2:D4 as an array. Pressing Ctrl+Shift+Enter confirms the formula as an array formula so every list item is tested.

Can I use more than three words in the search list?

Yes. Replace $D$2:$D$4 with the range containing all of your words, such as $D$2:$D$50. Keep the dollar signs if you plan to copy the formula down.

How can I avoid matching part of another word?

The wildcard formula matches text anywhere in A2, so it can match partial words. For exact whole-word matching, normalize the text and use delimiter-based logic or separate the words into individual cells before comparing them.

What does the formula return when none of the listed words appears in A2?

It returns "Nil" because the IF function uses that value when no COUNTIF result is found. You can replace "Nil" with any result you prefer, such as an empty string ("").

Will this formula work in WPS Spreadsheets?

Yes. WPS Spreadsheets supports Excel-compatible IF, COUNTIF, OR, and SUMPRODUCT formulas and can open .xlsx and .xls workbooks.