Sort one column based on another column--where column to be sorted consists of groups with duplicate values

lou89

New Member
Joined
Jan 18, 2018
Messages
1
Hi all,

Apologies for the long title, but I wanted to highlight that this is not just the typical 'sort one column based on another' question, but an extension of it.

I have data that is structured something like this:

[TABLE="width: 462"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD][/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Lorem ipsum dolor sit amet[/TD]
[TD][/TD]
[TD]A[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]consectetur adipiscing elit[/TD]
[TD][/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]Nam posuere maximus tellus[/TD]
[TD][/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]efficitur convallis odio ullamcorper ac[/TD]
[TD][/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Sed ex erat[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]efficitur et metus eget[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]congue finibus ipsum[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]Nunc pretium sit amet massa nec dictum[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]Pellentesque id mauris imperdiet[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]porta est eget[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]imperdiet lacus[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]Proin nisl purus[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I would like to reorder Column A and Column B (Column B should reorder when Column A is reordered) based on the order in Column D.

The outcome should look something like this:

[TABLE="width: 345"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Lorem ipsum dolor sit amet[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]Nam posuere maximus tellus[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]consectetur adipiscing elit[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]efficitur convallis odio ullamcorper ac[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Sed ex erat[/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]efficitur et metus eget[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]Nunc pretium sit amet massa nec dictum[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]congue finibus ipsum[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]B[/TD]
[TD]porta est eget[/TD]
[/TR]
[TR]
[TD]C[/TD]
[TD]imperdiet lacus[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]Pellentesque id mauris imperdiet[/TD]
[/TR]
[TR]
[TD]E[/TD]
[TD]Proin nisl purus[/TD]
[/TR]
</tbody>[/TABLE]

"=MATCH(A1,D:D,FALSE)" wouldn't work for me in this case because Columns A-B contain groups of data (denoted as separated by blank rows here) and I would like to keep the order within groups instead of having all the 'A's coming together, 'B's coming together, etc.

Just wondering if there's any way to achieve this.

Would greatly appreciate any help or advice at all. Thanks so much!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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