Finding "nth" match

mcorydon

New Member
Joined
Jan 6, 2014
Messages
16
I have been working on this formula for a while and cannot find a solution without having a super long and complex nested if statement. For the below table, I want to be able to choose a name (Bernard for example) and have a formula tell me the column name of the first cell with a value greater than 0 (Orange). I then want to have a formula next to that one that pulls the second value, then third, then forth (if applicable). Can anyone think of what formula will accomplish this (ideally not a ctrl-shift-enter)

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]red[/TD]
[TD]orange[/TD]
[TD]yellow[/TD]
[TD]green[/TD]
[/TR]
[TR]
[TD]andy[/TD]
[TD]10[/TD]
[TD]20[/TD]
[TD]50[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]bernard[/TD]
[TD][/TD]
[TD]30[/TD]
[TD]40[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Carl[/TD]
[TD]50[/TD]
[TD][/TD]
[TD][/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]Daphne[/TD]
[TD][/TD]
[TD][/TD]
[TD]100[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

The answer should look like this

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]first[/TD]
[TD]second[/TD]
[TD]third[/TD]
[TD]fourth[/TD]
[/TR]
[TR]
[TD]andy[/TD]
[TD]red[/TD]
[TD]orange[/TD]
[TD]yellow[/TD]
[TD]green[/TD]
[/TR]
[TR]
[TD]bernard[/TD]
[TD]orange[/TD]
[TD]yellow[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]carl[/TD]
[TD]red[/TD]
[TD]green[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]daphne[/TD]
[TD]yellow[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Thank You (I'm almost certain Index is needed()
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Book1
ABCDEFGHIJK
1redorangeyellowgreenfirstsecondthirdfourth
2andy10205050daphneyellow
3bernard3040carlredgreen
4carl5010bernardorangeyellow
5daphne100andyredorangeyellowgreen
Sheet1
Cell Formulas
RangeFormula
H2{=IFERROR(INDEX($B$1:$E$1,SMALL(IF(INDEX($B$2:$E$5,MATCH($G2,$A$2:$A$5,0),)>0,COLUMN(INDEX($B$2:$E$5,MATCH($G2,$A$2:$A$5,0),))-COLUMN($B$2)+1),COLUMNS($H2:H2))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.


Copy H2 formula across and down as necessary.

WBD
 
Upvote 0
If you'd prefer, here is a similar one but does not require the Ctrl+Shift+Enter confirmation.

Excel Workbook
ABCDE
1redorangeyellowgreen
2andy10205050
3bernard3040
4carl5010
5daphne100
6
7
8firstsecondthirdfourth
9daphneyellow
10carlredgreen
11bernardorangeyellow
12andyredorangeyellowgreen
mcorydon
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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