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.

Cycle Highlights in Google Sheets – Rotate Highlights Daily

Want to cycle highlights in Google Sheets every day? Whether you're rotating a meal...

Filter Rows Containing Multiple Selected Values in Google Sheets

This tutorial explains how to filter rows in a column containing multiple selected drop-down...

Two-Way Lookup with XLOOKUP in Google Sheets

When you need to look up one search key vertically and another horizontally, you...

How to Filter by Total in Google Sheets Pivot Tables

Google Sheets offers many tools to summarize and analyze data, but Pivot Tables are...

More like this

XLOOKUP with Match Mode 3 in Excel (Regex Match)

XLOOKUP becomes more powerful in Excel with the new match mode 3, which enables...

Hierarchical Number Sorting in Excel with Modern Functions

A hierarchical numbering system in Excel allows you to organize data into a clear,...

Dynamic Formula to Sum Every 7 Rows in Excel

To sum every 7 rows, you can use either a drag-down formula or a...

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.