## Retrieve first matching value in cell against a list

Suppose you have a list of keywords, to retrieve the first keyword that appeared in a specific cell, while the cell contains several other values, you will have to use an INDEX and MATCH formula with the help of AGGREGATE and SEARCH functions.

#### How to retrieve first matching value in cell against a list?

To get the first matched keyword in a cell against the Keywords list as the table shown above, it means that we need to perform a contain match rather than an exact match. To do so, you can use the SEARCH function to feed the positions of the keywords appeared in the cell in numeric numbers into the AGGREGATE function. Then AGGREGATE will get the smallest number by setting its function_num to 15 and the ref2 argument to 1. Then use MATCH to locate the first smallest value and feed the position number to INDEX to retrieve the value at that position.

#### Generic syntax

=INDEX(keyword_rng,MATCH(AGGREGATE(15,6,SEARCH(keyword_rng,lookup_cell),1),SEARCH(keyword_rng,lookup_cell),0))

√ Note: This is an array formula that requires you to enter with Ctrl + Shift + Enter.

• keyword_rng: The range of cells with keywords.
• lookup_cell: The cell to lookup if it contains the keywords.

To retrieve the first matched keyword appeared in cell B5 against the Keywords column, please copy or enter the formula below in the cell C5, and press Ctrl + Shift + Enter to get the result:

=INDEX(\$E\$5:\$E\$7,MATCH(AGGREGATE(15,6,SEARCH(\$E\$5:\$E\$7,B5),1),SEARCH(\$E\$5:\$E\$7,B5),0))

√ Note: The dollar signs (\$) above indicate absolute references, which means the keyword_rng in the formula won't change when you move or copy the formula to other cells. However, there are no dollar signs added to the lookup_cell since you want it to be dynamic. After entering the formula, drag the fill handle down to apply the formula to the below cells.

#### Explanation of the formula

=INDEX(\$E\$5:\$E\$7,MATCH(AGGREGATE(15,6,SEARCH(\$E\$5:\$E\$7,B5),1),SEARCH(\$E\$5:\$E\$7,B5),0))

• SEARCH(\$E\$5:\$E\$7,B5): The SEARCH function returns the position of each keyword from the range \$E\$5:\$E\$7 when found in numeric numbers, and the #VALUE! error if not found. The result would be in an array like this: {15;11;#VALUE!}.
• AGGREGATE(15,6,SEARCH(\$E\$5:\$E\$7,B5),1)=AGGREGATE(15,6,{15;11;#VALUE!},1): The AGGREGATE function with a function_num of 15 and option of 6 will return the smallest value in the array according to the ref2 argument 1, while ignoring error values. So, the snippet would return 11.
• MATCH(AGGREGATE(15,6,SEARCH(\$E\$5:\$E\$7,B5),1),SEARCH(\$E\$5:\$E\$7,B5),0)=MATCH(11,{15;11;#VALUE!},0): The match_type 0 forces the MATCH function to perform an exact match and return the position of 11 in the array {15;11;#VALUE!}. So, the function will return 2.
• INDEX(\$E\$5:\$E\$7,MATCH(AGGREGATE(15,6,SEARCH(\$E\$5:\$E\$7,B5),1),SEARCH(\$E\$5:\$E\$7,B5),0))=INDEX(\$E\$5:\$E\$7,2): The INDEX function then returns the 2nd value in the range \$E\$5:\$E\$7, which is bbb.

#### Remark

• If there are no keywords in a cell, a #NUM! error will be returned.
• The formula is not case-sensitive. To perform a case-sensitive match, you can simply replace the SEARCH function withFIND.

#### Related functions

Excel INDEX function

The Excel INDEX function returns the displayed value based on a given position from a range or an array.

Excel MATCH function

The Excel MATCH function searches for a specific value in a range of cells, and returns the relative position of the value.

Excel SEARCH function

In Excel, the SEARCH function can help you to find the position of a specific character or substring from the given text string as following screenshot shown. This tutorial, I will introduce how to use this SEARCH function in Excel.

Excel AGGREGATE function

The Excel AGGREGATE function returns an aggregate of calculations such as SUM, COUNT, SMALLL and so on with the option to ignore errors and hidden rows.

#### Related Formulas

Retrieve first list value from a cell

To retrieve the first keyword that are listed in a range from a specific cell, while the cell contains one of several values, you will have to use a rather complex array formula with the INDEX, MATCH, ISNUMBER and SEARCH functions.

Exact match with INDEX and MATCH

If you need to find out the information listed in Excel about a specific product, movie or a person, etc., you should make a good use of the combination of INDEX and MATCH functions.

Check if a cell contains a specific text

Here the tutorial provides some formulas to check if a cell contains a specific text and return TRUE and FALSE as below screenshot shown, and explains the arguments and how the formulas works.

Check if cell contains all of many things

Supposing in Excel, there is a list of values in column E, you want to check if the cells in column B contain all of the values in column E, and return TRUE or FALSE as below screenshot shown. Here in this tutorial, it provides a formula to solve this task.

Check if cell contains one of many things

This tutorial provides a formula to check if a cell contains one of several values in Excel, and explains the arguments in the formula and how the formula work.

### The Best Office Productivity Tools

#### Kutools for Excel - Helps You To Stand Out From Crowd

 🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions… Popular Features: Find, Highlight or Identify Duplicates  |  Delete Blank Rows  |  Combine Columns or Cells without Losing Data  |  Round without Formula ... Super VLookup: Multiple Criteria  |  Multiple Value  |  Across Multi-Sheets  |  Fuzzy Lookup... Adv. Drop-down List: Easy Drop Down List  |  Dependent Drop Down List  |  Multi-select Drop Down List... Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Columns to Select Same & Different Cells ... Featured Features: Grid Focus  |  Design View  |  Big Formula Bar  |  Workbook & Sheet Manager | Resource Library (Auto Text)  |  Date Picker  |  Combine Worksheets  |  Encrypt/Decrypt Cells  |  Send Emails by List  |  Super Filter  |  Special Filter (filter bold/italic/strikethrough...) ... Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters ...)  |  50+ Chart Types (Gantt Chart ...)  |  40+ Practical Formulas (Calculate age based on birthday ...)  |  19 Insertion Tools (Insert QR Code, Insert Picture from Path ...)  |  12 Conversion Tools (Numbers to Words, Currency Conversion ...)  |  7 Merge & Split Tools (Advanced Combine Rows, Split Excel Cells ...)  |  ... and more

Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need is Just A Click Away...

#### Office Tab - Enable Tabbed Reading and Editing in Microsoft Office (include Excel)

• One second to switch between dozens of open documents!
• Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
• Increases your productivity by 50% when viewing and editing multiple documents.
• Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.