Function Problems

Search Text and Return an Adjacent Value in Excel

Maira MehtabMaira Mehtab Nov 25, 2026 871 views

Question details

Find a number within text and return the corresponding value from another range, including when a text cell contains multiple numbers.

Search Text and Return an Adjacent Value in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet has text strings in one range and corresponding item values in another. The user wants to find a search value anywhere in a string and return a matching item value.
Observed behavior
The desired formula should find the search value within a cell, even if the cell contains other numbers, and return the selected matching row's value.
Before you start

Set up two single-column ranges with corresponding rows: HTS_COMBO for the text to search and ITEM_NUMS for the values to return. Enter the search value in J4 and a positive match number, such as 1, in Q8.

Solution 1Recommended

Use SEARCH, INDEX, and SMALL to return a matching value

Use this formula to find a number anywhere in each text cell and return the first or another matching row's item value.

SEARCH checks whether the value in J4 appears anywhere in each HTS_COMBO cell. SMALL selects the match number specified in Q8, and INDEX returns the corresponding value from ITEM_NUMS.

The ranges must have the same number of rows and be aligned. The formula returns one result per matching row, even if the search value appears more than once in that cell.

1
Define the ranges

In Excel, select each single-column range and use Formulas > Define Name to name the text range HTS_COMBO and the corresponding return range ITEM_NUMS.

2
Enter the search criteria

Type the number or text to find in J4. Type 1 in Q8 for the first matching row, 2 for the second, and so on.

3
Enter the formula

Select the result cell and enter =INDEX(ITEM_NUMS,SMALL(IF(ISNUMBER(SEARCH(J$4,HTS_COMBO)),ROW(HTS_COMBO)-MIN(ROW(HTS_COMBO))+1),Q8)).

4
Confirm the formula

Press Enter in modern Excel. In older Excel versions, confirm the array formula with Ctrl+Shift+Enter instead.

Use SEARCH, INDEX, and SMALL to return a matching value
Substring matching: SEARCH matches text within a larger string, so searching for 12 also matches 112. If Q8 exceeds the number of matching rows, the formula returns a #NUM! error.
Search and return matching values

Find matching text and return item values in WPS Spreadsheets

Use the same SEARCH, INDEX, and SMALL formula in WPS Spreadsheets to find a number within text and return a value from an aligned range.

  1. 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 2. Prepare the ranges: Create aligned single-column ranges named HTS_COMBO and ITEM_NUMS using the name box or the named-range controls on the Formulas tab.
  3. 3. Enter the criteria: Enter the number or text to find in J4 and the desired match number in Q8.
  4. 4. Apply the formula: In a result cell, enter =INDEX(ITEM_NUMS,SMALL(IF(ISNUMBER(SEARCH(J$4,HTS_COMBO)),ROW(HTS_COMBO)-MIN(ROW(HTS_COMBO))+1),Q8)). Press Enter, or use Ctrl+Shift+Enter if your version requires array-formula entry.
Search for a number anywhere in a text cellReturn the first or another matching row's item valueWork with Microsoft Excel XLS and XLSX filesUse familiar spreadsheet formulas and named ranges
microsoft office alternative - wps office

Frequently Asked Questions

Can the formula find either number in a cell containing multiple numbers?

Yes. Enter the number you want to find in J4; SEARCH checks for it anywhere in each HTS_COMBO cell. Run the formula with a different search value to look for another number.

How do I return the second matching item?

Enter 2 in Q8. SMALL selects the second matching row, and INDEX returns its corresponding value from ITEM_NUMS.

Why does the formula return #NUM!?

The match number in Q8 may be greater than the number of matching rows. Check J4 and try 1 in Q8 to look for the first match.

Will searching for 12 match 112?

Yes. SEARCH performs a substring match, not an exact-number match. If exact numbers are required, the formula must account for the separators used in your text.

When should I use Ctrl+Shift+Enter?

In older Excel versions, select the formula cell and confirm the formula with Ctrl+Shift+Enter to enter it as an array formula. Modern Excel generally accepts Enter.