FormulaCraft

How to look up the nth matching value in Excel and Google Sheets

Topic:Lookups (any direction)
Excel & Google Sheets
=IFERROR(INDEX($B$2:$B$6,SMALL(IF($A$2:$A$6="Alice",ROW($A$2:$A$6)-ROW($A$2)+1),2)),"")

Verified example

Computed by a real spreadsheet engine on the sample data below.

NameTask
AliceDesign
BobDev
AliceReview
AliceTesting

=IFERROR(INDEX($B$2:$B$6,SMALL(IF($A$2:$A$6="Alice",ROW($A$2:$A$6)-ROW($A$2)+1),2)),"")

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1Build the IF array that returns the relative row numbers of matches: IF($A$2:$A$100="Alice",ROW($A$2:$A$100)-ROW($A$2)+1) produces row numbers where Alice appears, FALSE elsewhere.
  2. 2Use SMALL(...,n) to extract the nth smallest row number from that array — SMALL(...,2) gives the 2nd match's row.
  3. 3Wrap in INDEX to retrieve the value: =INDEX($B$2:$B$100,SMALL(IF(...),2)). In Excel 2019 confirm with Ctrl+Shift+Enter; wrap in IFERROR to suppress errors when fewer than n matches exist.

Tips

Need it for your exact data?

Describe your columns in plain English and get the precise formula for your sheet, with the right Excel or Sheets syntax.

Frequently asked

How do I look up the last matching value instead of the nth?

Use LARGE instead of SMALL with 1 as the k argument: =INDEX($B$2:$B$100,LARGE(IF($A$2:$A$100="Alice",ROW($A$2:$A$100)-ROW($A$2)+1),1)) returns the last match.

More on Lookups (any direction)

See all →

Formulas used

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: