Retrieve nth match with VLOOKUP
Suppose you have a list of values and their corresponding information, to retrieve the related information of the nth match of a value, you can use a formula based on the VLOOKUP function.
How to retrieve information associated with the nth match of a value with VLOOKUP?
To use the VLOOKUP function to get the information about the 1st, 2nd, and 3rd matches of Pencil in the table as shown above, you should first add a helper column to the left of your table with a COUNTIF formula as shown below. The helper column joins the products with the number of times that the products showed up. Then you can easily get the corresponding quantities of the nth matched pencils.
Formula in cell A5: =B5&":"&COUNTIF($B$5:B5,B5).
- lookup_value: The value you specified to lookup its nth match. Here refers to Pencil.
- n: Indicate the nth match. To find the 1st match of a value, set n as 1; to find the 2nd match, set n as 2.
- lookup_array: The range to retrieve the related information about the nth match from. Here refers to the whole data range including the helper column.
- col_num: The column number that indicates from which column of the lookup_array to return the information corresponding to the nth match from.
To get the information about the 1st match of Pencil, please copy or enter the formula below in the cell G7, and press Enter to get the result:
√ Note: The dollar signs ($) above indicate absolute references, which means the lookup_value and lookup_array 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 cell reference of n 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
Here we use the formula below as an example:
- The range_lookup FALSE asks the function to perform an exact match.
- The col_num 3 indicates that the matched value will be returned from the 3rd column of the range $A$5:$C$11.
- The snippet $F$4&":"&E8 indicates to lookup the 2nd (value in E8) match of Pencil (value in $F$4). In text form, the snippet is like this: Pencil:2.
- VLOOKUP now retrieves the corresponding quantity information from the 3rd column of the range $A$5:$C$11 that matches Pencil:2, which is 478.
Excel VLOOKUP function
The Excel VLOOKUP function searches for a value by matching on the first column of a table and returns the corresponding value from a certain column in the same row.
Retrieve nth match with INDEX
To find the nth match of a value from a range and retrieve its corresponding data, you can use a formula based on the INDEX, ROW, SMALL, and IF functions.
Exact match with VLOOKUP
To find out the information listed in Excel about a specific product, movie or a person, etc., you should take advantage of the VLOOKUP function.
Partial match with VLOOKUP
There are times when you need Excel to retrieve data based on partial information. To solve the problem, you can use a VLOOKUP formula together with wildcard characters - the asterisk (*) and question mark (?).
The Best Office Productivity Tools
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.
- 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.