Find 2nd and 3rd highest numbers in a row and return column header

centaur87

New Member
Joined
May 9, 2016
Messages
13
[TABLE="width: 670"]
<tbody style="box-sizing: inherit; border: 0px; margin: 0px; padding: 0px; vertical-align: top; -webkit-font-smoothing: antialiased; text-size-adjust: none;">[TR]
[TD]ETF-A[/TD]
[TD]ETF-B[/TD]
[TD]ETF-C[/TD]
[TD]ETF-D[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]27[/TD]
[TD]11[/TD]
[TD]11[/TD]
[/TR]
</tbody>[/TABLE]
[FONT=&quot]I cannot seem to write the formula that would return the column header of the second largest value.

In above Case, first Largest value is 27, it will return ETF-B
But 2nd largest has duplicate values, hence what formula shall i write to return [/FONT]
[FONT=&quot]the column header of the second largest value.

Best Regards.
[/FONT]
 
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][th]
D
[/th][th]
E
[/th][th]
F
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]ETF-A[/td][td]ETF-B[/td][td]ETF-C[/td][td]ETF-D[/td][td]
27​
[/td][td]ETF-B[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]
10​
[/td][td]
27​
[/td][td]
11​
[/td][td]
11​
[/td][td]
11​
[/td][td]ETF-C,ETF-D[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td][/td][td][/td][td][/td][td][/td][td]
10​
[/td][td]ETF-A[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td][/td][td][/td][td][/td][td][/td][td]
0​
[/td][td][/td][/tr]
[/table]

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
E
[/th][th]
F
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]
=MAX($A$2:$D$2)​
[/td][td]=TEXTJOIN(",",1,IF($A$2:$D$2=E1,$A$1:$D$1,""))[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]
=MAX(IF($A$2:$D$2<E1,$A$2:$D$2))​
[/td][td]=TEXTJOIN(",",1,IF($A$2:$D$2=E2,$A$1:$D$1,""))[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]
=MAX(IF($A$2:$D$2<E2,$A$2:$D$2))​
[/td][td]=TEXTJOIN(",",1,IF($A$2:$D$2=E3,$A$1:$D$1,""))[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]
=MAX(IF($A$2:$D$2<E3,$A$2:$D$2))​
[/td][td]=TEXTJOIN(",",1,IF($A$2:$D$2=E4,$A$1:$D$1,""))[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]


Formula in F1 is array so you have to accept it with Ctrl+Shift+Enter not just Enter.
 
Last edited:
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,240
Messages
6,170,951
Members
452,368
Latest member
jayp2104

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