Finding nth occurrence of a value

rigreene

New Member
Joined
Sep 17, 2014
Messages
4
I want to be able to find the nth value using VLOOKUP, INDEX, or something similar.

Example:

=VLOOKUP(2,A1:B5,2,0)
would return "Blue"

AB
13Green
22Blue
3
4Green
4
2Red
5
5Red

<tbody>
</tbody>

But, if I want it to find the 2nd "2" so that it returns "Red," how would I go about that?

Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi.

I notice that link appears to be a UDF solution. If you want a purely formula-based solution, use this array formula**:

=INDEX(B1:B5,SMALL(IF(A1:A5=C1,ROW(A1:A5)-MIN(ROW(A1:A5))+1),k))

where C1 holds the search value, e.g. 2, and k at the end should be replaced with a number representing which occurrence of that search value you wish to return, e.g. 1=1st, 2=2nd, etc.

Regards


**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
 
Upvote 0
Hi,

if you are using Excel 2010 (or newer versions ) you could give a chance to a standard formula

=IFERROR(INDEX($B$1:$B$5,AGGREGATE(15,6,ROW($A$1:$A$5)/($A$1:$A$5=2),ROW(A1))),"")

copying down the formula you get all the occurences

If it's of any help.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,172
Members
449,071
Latest member
cdnMech

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