Excel: Search Multiple Keywords in a Cell (New!)

Searching for multiple keywords in a cell is one of the most common tasks in Excel, and dynamic arrays have made it much simpler.

For example, consider the following text in cell A1: “The WFC collaborates closely with the WFP to address global hunger and promote sustainable food systems.

How do we search for the keywords “WFC,” “ex,” and “WFP” in cell A1 and return 1 and 3 or “1. World Food Council” and “3. World Food Programme” respectively? Because the first and third keywords are available in cell A1.

You can follow the approach below if you are using Microsoft 365 or Excel versions that support dynamic array functions such as LET and FILTER. The LET function is optional, though we have used it to improve the formula’s efficiency by avoiding repeated calculations. It also enhances the overall readability of the formula.

Excel Formula to Search For Multiple Keywords in a Cell

You can utilize the following formula to search for multiple keywords in cell A1 and return assigned values.

=LET(
   within_cell, A1,
   search_text, {"WFC", "ex", "WFP"},
   return_array, {"World Food Council", "ex-dividend", "World Food Program"},
   search_, IFERROR(SEARCH(search_text, within_cell), 0),
   FILTER(SEQUENCE(1, COLUMNS(return_array))&": "&return_array, search_, "")
)

Where:

  • {"WFC","ex","WFP"} represents the multiple keywords to search in cell A1.
  • {"World Food Council","ex-dividend","World Food Program"} represents the corresponding texts to return.

When using this Excel formula to search for keywords in a cell, replace the values in these two arrays. Both arrays should have an equal number of values.

Please see the formula and output in the screenshot below:

Search for Multiple Keywords in a Cell in Excel

Here are two important changes you can make to the formula to customize the output.

Customization #1:

If you don’t want to return any text and only want the sequences of matches like 1 and 3, remove the &": "&return_array part of the formula.
Output: {1, 3} indicates the first and third keywords match in the sentence.

Customization #2:

If you want the result without the sequence number prefix, remove the SEQUENCE(1, COLUMNS(return_array))&": "& part of the formula.
Output: {World Food Council, World Food Program}

Yes, you can!

Sometimes, case-sensitivity matters in keyword searches in Excel when you want to distinguish between uppercase and lowercase letters in the keywords.

For example, if you’re searching for the keyword “PW123#xy”, which is a password, and your text contains “pw123#xy” or “PW123#XY”, a case-sensitive search would only match “PW123#xy” and not the variations with different capitalization.

For case-sensitive multiple-keyword searches in Excel, you need to make one modification in the formula.

Substitute the function SEARCH with FIND. No other changes to the formula are required. Both share similar syntax; the only distinction is that SEARCH is case-insensitive, whereas FIND is case-sensitive.

Formula Explanation

Here is the key part of the multiple-keyword search formula: IFERROR(SEARCH(search_text, within_cell), 0)

Where the search words (search_text) are {"WFC", "ex", "WFP"} and the cell to search within (within_cell) is A1. We have utilized the LET function to define these two names: search_text and within_cell.

So, what happens here? The above formula is a multiple-keyword search formula that returns either the matching position or 0. In this case, it will return the array {5, 0, 39}. We named this search formula as search_.

Now, here is the formula expression that returns the output: FILTER(SEQUENCE(1, COLUMNS(return_array))&": "&return_array, search_, "")

This formula filters the return array {"World Food Council", "ex-dividend", "World Food Program"} (named return_array) prefixed by their sequence numbers wherever the search_ is greater than 0.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

How to Retrieve the Last Record in Each Group in Excel

As part of data analysis, you may need to retrieve the last record from...

More like this

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

How to Retrieve the Last Record in Each Group in Excel

As part of data analysis, you may need to retrieve the last record from...

How to Perform Case-Sensitive XLOOKUP in Excel with EXACT

We may not always need to perform a case-sensitive XLOOKUP for product names in...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.