Note: The other languages of the website are Google-translated. Back to English

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.

retrieve first matching value in cell against a list 1

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


√ 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:


√ 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.

retrieve first matching value in cell against a list 2

Explanation of the formula


  • 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.


  • 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 with FIND.

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

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300 powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) and save 80% time for you.

  • Designed for 1500 work scenarios, helps you solve 80% Excel problems.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 30-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years.
Ribbon of Excel (with Kutools for Excel installed)

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, Firefox, And New Internet Explorer.
Screen Shot of Excel (with Office Tab installed)
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations

Follow Us

Copyright © 2009 - | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL