Sorting Multiple Columns with duplicates

Erika7

New Member
Joined
Oct 14, 2013
Messages
3
I need to create a sorting method and/or macro to sort the entire table but with 4 of the columns (D-G below) being similarly sorted/grouped where values may be found in any (or all) of the 4. Please see the example below to get a better understanding of the situation. There are actually 31 columns, but I'm only showing 8 for example purposes. It should first sort by Date, then Location (Front, Right, Back, Left) based on Unique ID then the other hidden columns.

The part I'm getting stuck is sorting the Locations: I need it to be able to sort similar 'Unique IDs' based on the numbers found in the locations; however, the numbers can be found in any of the 4 locations and on any of the unique # rows. [TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]A1 Unique ID[/TD]
[TD]B Date[/TD]
[TD]C Type[/TD]
[TD]D Front[/TD]
[TD]E Right[/TD]
[TD]F Left[/TD]
[TD]G Back[/TD]
[TD]H Time[/TD]
[/TR]
[TR]
[TD]2 1001[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]23[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]3 1002[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]21[/TD]
[TD]0[/TD]
[TD]70[/TD]
[TD]0[/TD]
[TD]0.20[/TD]
[/TR]
[TR]
[TD]4 1003[/TD]
[TD]1/1[/TD]
[TD]B[/TD]
[TD]21[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]5 1004[/TD]
[TD]1/1[/TD]
[TD]C[/TD]
[TD]0[/TD]
[TD]23[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]6 1005[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]70[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]7 1006[/TD]
[TD]1/2[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]29[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]8 1007[/TD]
[TD]1/2[/TD]
[TD]A[/TD]
[TD]17[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
</tbody>[/TABLE]

See below for ideal answer. Note that the rows are sorted first by Date, then the Location IDs are sorted adjacently (it should know which line to sort next based on the Unique ID order - smallest ID always goes first)

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]A1 Unique ID[/TD]
[TD]B Date[/TD]
[TD]C Type[/TD]
[TD]D Front[/TD]
[TD]E Right[/TD]
[TD]F Left[/TD]
[TD]G Back[/TD]
[TD]H Time[/TD]
[/TR]
[TR]
[TD]2 1001[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]23[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]3 1004[/TD]
[TD]1/1[/TD]
[TD]C[/TD]
[TD]0[/TD]
[TD]23[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]4 1005[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]70[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]5 1002[/TD]
[TD]1/1[/TD]
[TD]A[/TD]
[TD]21[/TD]
[TD]0[/TD]
[TD]70[/TD]
[TD]0[/TD]
[TD]0.20[/TD]
[/TR]
[TR]
[TD]6 1003[/TD]
[TD]1/1[/TD]
[TD]B[/TD]
[TD]21[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]7 1006[/TD]
[TD]1/2[/TD]
[TD]B[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]29[/TD]
[TD]0.10[/TD]
[/TR]
[TR]
[TD]8 1007[/TD]
[TD]1/2[/TD]
[TD]A[/TD]
[TD]17[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0.10
[/TD]
[/TR]
</tbody>[/TABLE]

I understand this may be confusing, but any help is greatly appreciated! Thanks in advance!!!
 
It is a little confusing. What is the logic that 1005 (with Front = 70) comes before 1002 (with Front = 21 & Left = 70)?
 
Upvote 0
Sorry, you're correct. The final answer should have ID 1003 and 1005 flipped. Thank you for catching that.


It is a little confusing. What is the logic that 1005 (with Front = 70) comes before 1002 (with Front = 21 & Left = 70)?
 
Upvote 0

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