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

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.

retrieve nth match with vlookup 1

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.

retrieve nth match with vlookup 2

Formula in cell A5: =B5&":"&COUNTIF($B$5:B5,B5).

Generic syntax

=VLOOKUP(lookup_value&":"&n,lookup_array,col_num,FALSE)

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

=VLOOKUP($F$4&":"&E7,$A$5:$C$11,3,FALSE)

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

retrieve nth match with vlookup 3

Explanation of the formula

Here we use the formula below as an example:

=VLOOKUP($F$4&":"&E8,$A$5:$C$11,3,FALSE)

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

Related functions

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.


Related Formulas

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.

Retrieve information associated with lowest n values

To retrieve data that are corresponding to the smallest, 2nd smallest, or nth smallest value in a list, table or row in Excel, you can use an INDEX and MATCH formula together with the SMALL 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

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