Sorting Rows, then use Index/Match to return data headers

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
558
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Thank you in advance for the support of this forum.

I have a range where each row needs to be individually sorted, then the range headers returned.

In this range:
1. The first group of columns, 1-4, is the raw data.
2. The second group of 4 columns, 5-8, is the sorted raw data from max to min. Because each row is sorted indivually, I have used the Large function in each cell to do the sort.
if anybody has a better suggestion, how to this, I would welcome some ideas.
3. The third group of 4 columns, 9-12, I used Index/Match to return the columns headers of columns 1-4.

No problem so far.

where the issue pops up is that Index/Match will only return the first occurance. It is highly likely that I will get repeated values in the raw data.

If I use a complicated IF or LET function I may be able to return the 2nd ,3rd, 4th values appropriatly, but I do not believe that is the best way to go.

Columns 13 -16, is the expected results that should appear in columns 9 - 12.

PS, I did try to use the xl2bb to make this a bit easier to read, and give the equations, b ut my PC kept hanging. Sorry.

All suggestions are very much appreciated.

FirmGoodSoftHeavySorted PlacesSorted ConditionsShould Be
0​
6​
2​
1​
6​
2​
1​
0​
GoodSoftHeavyFirm
0​
2​
4​
3​
4​
3​
2​
0​
SoftHeavyGoodFirm
0​
1​
5​
3​
5​
3​
1​
0​
SoftHeavyGoodFirm
0​
8​
1​
0​
8​
1​
0​
0​
GoodSoftFirmFirm
0​
1​
6​
2​
6​
2​
1​
0​
SoftHeavyGoodFirm
0​
5​
3​
2​
5​
3​
2​
0​
GoodSoftHeavyFirm
0​
3​
4​
3​
4​
3​
3​
0​
SoftGoodGoodFirmSoftGoodHeavyFirm
0​
2​
5​
3​
5​
3​
2​
0​
SoftHeavyGoodFirm
0​
4​
4​
1​
4​
4​
1​
0​
GoodGoodHeavyFirmGoodSoftHeavyFirm
0​
0​
4​
2​
4​
2​
0​
0​
SoftHeavyFirmFirm
0​
3​
4​
3​
4​
3​
3​
0​
SoftGoodGoodFirmSoftGoodHeavyFirm
0​
0​
1​
0​
1​
0​
0​
0​
SoftFirmFirmFirmGoodFirmGoodHeavy
0​
6​
4​
0​
6​
4​
0​
0​
GoodSoftFirmFirmGoodSoftFirmHeavy
0​
10​
8​
2​
10​
8​
2​
0​
GoodSoftHeavyFirm
0​
6​
2​
2​
6​
2​
2​
0​
GoodSoftSoftFirmGoodSoftHeavyFirm
0​
2​
0​
0​
2​
0​
0​
0​
GoodFirmFirmFirmGoodFirmSoftHeavy
0​
2​
0​
2​
2​
2​
0​
0​
GoodGoodFirmFirmGoodSoftFirmHeavy
0​
1​
2​
0​
2​
1​
0​
0​
SoftGoodFirmFirmSoftGoodFirmHeavy
0​
0​
2​
1​
2​
1​
0​
0​
SoftHeavyFirmFirmSoftHeavyFirmGood
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this (formulas in columns E and I only)
Note that if your goal is to get the headers then you don't actually need the Column E formula.

22 05 29.xlsm
ABCDEFGHIJKL
1FirmGoodSoftHeavySorted PlacesSorted Conditions
206216210GoodSoftHeavyFirm
302434320SoftHeavyGoodFirm
401535310SoftHeavyGoodFirm
508108100GoodSoftFirmHeavy
601626210SoftHeavyGoodFirm
705325320GoodSoftHeavyFirm
803434330SoftGoodHeavyFirm
902535320SoftHeavyGoodFirm
1004414410GoodSoftHeavyFirm
1100424200SoftHeavyFirmGood
1203434330SoftGoodHeavyFirm
1300101000SoftFirmGoodHeavy
1406406400GoodSoftFirmHeavy
150108210820GoodSoftHeavyFirm
1606226220GoodSoftHeavyFirm
1702002000GoodFirmSoftHeavy
1802022200GoodHeavyFirmSoft
1901202100SoftGoodFirmHeavy
2000212100SoftHeavyFirmGood
Sort Rows
Cell Formulas
RangeFormula
E2:H20E2=SORT(A2:D2,,-1,1)
I2:L20I2=SORTBY(A$1:D$1,A2:D2,-1)
Dynamic array formulas.
 
Upvote 0
Solution
Oh my :-) Thank you Peter. I have never used the SORTBY function, but because of your valuable assistance, I have now delete several blocks of very unnecessay formulas. I just spent an hour trying to see how i could this with VBA.

And yet, the goal was only to retirve the headers

Again, my sincere thanks..
 
Upvote 0
You're welcome. Glad I had a last-minute idea to put in the note about headers only! 😎
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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