How to Search for Cells Containing Specific Text in Excel Using SEARCH and FILTER Functions

スポンサーリンク
スポンサーリンク

Search for Cells Containing Specific Text

This article explains how to search for cells containing specific text in Excel. For example, it can be useful when looking for a keyword like "Product A" within a list of product names.

If you just want to find a cell quickly, press Ctrl + F to open Excel's Find feature. If you want to use formulas to check for specific text or extract matching data, you can use the SEARCH and FILTER functions.

Using the SEARCH Function to Find Specific Text

The SEARCH function returns the starting position of specified text within a cell. It is case-insensitive and supports partial matches.

For example, searching for "Product A" will find both "Product A" and "Product A Special Edition".

Example in Excel

A B C D
1 Product Name Price SEARCH Formula Result
2 Product A 1000 =SEARCH("Product A", A2) 1
3 Product B 2000 =SEARCH("Product A", A3) #VALUE!
4 Product A Special Edition 1500 =SEARCH("Product A", A4) 1
5 Product C 800 =SEARCH("Product A", A5) #VALUE!

The formulas shown in column C are examples, while column D illustrates their calculated results.

Steps

  1. Enter the product names in cells A2:A5.
  2. Select cell C2, where you want to display the search result.
  3. Enter the following formula:

Formula Example

=SEARCH("Product A", A2)

This formula searches for "Product A" in cell A2 and returns the position where the matching text begins.

If the text is found at the beginning of the cell, the result is 1. If the text is not found, SEARCH returns a #VALUE! error.

You can copy the formula down from C2 to C5 to check the remaining cells. Excel automatically adjusts the references to A3, A4, and A5.

In Excel versions that support dynamic arrays, you can also enter the following formula in C2:

=SEARCH("Product A", A2:A5)

This returns four results that automatically spill into C2:C5. Make sure C3:C5 are empty before entering this formula. The results will include #VALUE! errors for cells without a match.

Returning Yes/No (✓/✗) Instead of Position

If you want to identify whether a cell contains the specified text without displaying the position or an error, combine SEARCH with the IF and ISNUMBER functions.

Use the following formula to display ✓ if the text exists and ✗ if it does not:

=IF(ISNUMBER(SEARCH("Product A", A2)), "✓", "✗")

The formula returns:

  • ✓ when "Product A" is found in the cell.
  • ✗ when "Product A" is not found.

The ISNUMBER function checks whether SEARCH returns a numeric position. If SEARCH returns #VALUE!, ISNUMBER returns FALSE, allowing IF to display ✗ instead of an error.

Displayed Result

The SEARCH function returns the starting position of the specified text. For example:

  • In "Product A", it returns 1.
  • In "Product A Special Edition", it returns 1.
  • In "Product C includes Product A", it returns 20, because "Product A" begins at the 20th character.
  • In "Product B", it returns #VALUE! because the specified text is not present.

Using the FILTER Function to Extract Cells Containing Specific Text

The FILTER function can extract only those cells that contain the specified text. By combining FILTER with SEARCH and ISNUMBER, you can create a list of matching values automatically.

Example in Excel

Suppose column A contains product names and column B contains prices. The results of the FILTER function can be displayed in column C.

A B C D
1 Product Name Price Filtered Result
2 Product A 1000 Product A
3 Product B 2000 Product A Special Edition
4 Product A Special Edition 1500
5 Product C 800

Steps

  1. Enter the product names in A2:A5.
  2. Select cell C2, where you want to display the extracted results.
  3. Enter the following formula:

Formula Example

=FILTER(A2:A5, ISNUMBER(SEARCH("Product A", A2:A5)), "No Match")

This formula searches the range A2:A5 and extracts only the cells containing "Product A".

The functions work together as follows:

  • SEARCH("Product A", A2:A5): Searches each cell for the specified text.
  • ISNUMBER(...): Returns TRUE for cells containing the search term and FALSE for cells without a match.
  • FILTER(A2:A5, ...): Extracts only the values corresponding to TRUE results.
  • "No Match": Displays this message if no matching cells are found.

After pressing Enter, Excel automatically displays the matching values in C2 and C3. You do not need to copy the formula down.

Displayed Result

The FILTER function extracts the following values:

  • Product A
  • Product A Special Edition

If you want to extract both the product name and its price, rather than only the product name, use:

=FILTER(A2:B5, ISNUMBER(SEARCH("Product A", A2:A5)), "No Match")

This formula extracts the complete matching rows from columns A and B. Enter it in an empty area, such as E2, to avoid overwriting the original data.

Notes

  • Excel compatibility: The FILTER function is available in Excel for Microsoft 365, Excel 2021, and Excel 2024. It is not available in Excel 2019 or earlier perpetual versions.
  • SEARCH compatibility: The SEARCH function is supported in older Excel versions, but automatic spilling of array results requires a version that supports dynamic arrays.
  • No matching data: If FILTER finds no matching values and the optional third argument is omitted, it may return a #CALC! error. Use "No Match" or another appropriate value as the third argument.
  • Dynamic arrays: FILTER automatically expands the output range. If an existing value blocks that range, Excel displays a #SPILL! error.
  • Case sensitivity: SEARCH is case-insensitive. For case-sensitive searches, use the FIND function instead.
  • Partial matches: Searching for "Product A" also finds longer strings containing that phrase.
  • Wildcard characters: SEARCH supports * and ? as wildcards. To search for these characters literally, precede them with a tilde (~).
  • Blank search terms: When the search term is supplied by a cell reference, check whether that cell is empty if you do not want an empty search term to match all values.

Conclusion

  • Use the SEARCH function to determine the position of specified text within a cell.
  • Combine SEARCH, ISNUMBER, and IF to display a simple match or no-match result.
  • Use the FILTER function with SEARCH and ISNUMBER to extract matching cells or entire rows.
  • Both approaches support partial text matching, making them useful for finding product names, keywords, and other text within Excel datasets.