Lookup to return nth value

tinderbox22

Board Regular
Joined
Mar 9, 2010
Messages
56
Office Version
  1. 365
Platform
  1. Windows
I'm trying to figure out how to lookup values in a small table where there may be more than one result that matches the lookup value.

In cells A1:B10, assume numbers in A1:A10 and names in B1:B10. I want to look up the numbers to return the names. If A5 and A8, for example, are the same number, a simple XLOOKUP won't work. How do I go about returning the next result instead of the first result twice?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Do you want to return all of the matching results or just a particular one? You’ve mentioned the nth value. Where is n?
Which version of Excel are you using?
 
Upvote 0
One approach:
Book2
ABCDE
12amatchnResult
26b52h
31c53i
47d72j
53e73not found
65f
79g
85h
95i
107j
Sheet3
Cell Formulas
RangeFormula
E2:E5E2=IFERROR(INDEX(FILTER($B$1:$B$10,$A$1:$A$10=C2),D2),"not found")
 
Upvote 0
Do you want to return all of the matching results or just a particular one? You’ve mentioned the nth value. Where is n?
Which version of Excel are you using?
I’d like to return all matching values. So first, second, third if it’s there, etc. using 365
 
Upvote 0
using 365
Please update your forum profile (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Is this what you are after?

24 03 24.xlsm
ABCD
11Name12
25Name2Name3
32Name3Name5
43Name4Name7
52Name5Name10
63Name6
72Name7
81Name8
95Name9
102Name10
Lookup
Cell Formulas
RangeFormula
D2:D5D2=FILTER(B1:B10,A1:A10=D1,"")
Dynamic array formulas.
 
Upvote 0
Getting closer. I believe I figured it out. I'll just use the SORTBY function rather than a lookup.
In your example, instead of D1=2, D1:D10 = 1,2,3...10. My formula would go in E1:E10, using D1:D10 as lookup values. So essentially, I'm ranking the results. I got tripped up on the 'lookup' but it's really just a ranking/sorting function. Thank you all for your quick responses!
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top