group 2 columns together before sorting

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
476
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Can someone help me figure out the code for grouping 2 columns together before sorting by columns?

example data:
where columns A & B need to be grouped together, C & D together, E & F together, etc...
When the sort is done it is only to sort by the name column (first column in each group of 2... A = Steve, C = John, E = Zeke... etc)

so before sort:

[TABLE="class: grid, width: 626"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"] A[/TD]
[TD="align: center"] B[/TD]
[TD="align: center"] C[/TD]
[TD="align: center"] D[/TD]
[TD="align: center"] E[/TD]
[TD="align: center"] F[/TD]
[TD="align: center"] G[/TD]
[TD="align: center"] H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] Steve[/TD]
[TD="align: center"]6/9/2010[/TD]
[TD="align: center"]John[/TD]
[TD="align: center"]1/1/2017[/TD]
[TD="align: center"]Zeke[/TD]
[TD="align: center"]5/5/2013[/TD]
[TD="align: center"]Adam[/TD]
[TD="align: center"]2/5/2008[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"]12/17/2014[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8/5/2013[/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/18/2012[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8/4/2015[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"]9/1/2010[/TD]
[TD="align: center"][/TD]
[TD="align: center"]10/2/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]11/19/2014[/TD]
[TD="align: center"][/TD]
[TD="align: center"]5/27/2011[/TD]
[/TR]
</tbody>[/TABLE]



and after sorting and with grouping every 2 columns together:

[TABLE="class: grid, width: 626"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"] A[/TD]
[TD="align: center"] B[/TD]
[TD="align: center"] C[/TD]
[TD="align: center"] D[/TD]
[TD="align: center"] E[/TD]
[TD="align: center"] F[/TD]
[TD="align: center"] G[/TD]
[TD="align: center"] H[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"] Adam[/TD]
[TD="align: center"]2/5/2008[/TD]
[TD="align: center"]John[/TD]
[TD="align: center"]1/1/2017[/TD]
[TD="align: center"]Steve[/TD]
[TD="align: center"]6/9/2010[/TD]
[TD="align: center"]Zeke[/TD]
[TD="align: center"]5/5/2013[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8/4/2015[/TD]
[TD="align: center"][/TD]
[TD="align: center"]8/5/2013[/TD]
[TD="align: center"][/TD]
[TD="align: center"]12/17/2014[/TD]
[TD="align: center"][/TD]
[TD="align: center"]1/18/2012[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"]5/27/2011[/TD]
[TD="align: center"][/TD]
[TD="align: center"]10/2/2016[/TD]
[TD="align: center"][/TD]
[TD="align: center"]9/1/2010[/TD]
[TD="align: center"][/TD]
[TD="align: center"]11/19/2014[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The objective is not clear. Would it not be simpler to list the dates beneath the applicable names? It would definitely simplify the sorting.
 
Upvote 0
The objective is not clear. Would it not be simpler to list the dates beneath the applicable names? It would definitely simplify the sorting.

Ok... I was trying to keep my question simple so I didnt needlessly complicate what I was after... but i guess some context to what I am actually attempting to do would clarify the objective;

Here is my spreadsheet with just the NAME column showing;
i3wdv7.jpg


Here it is with the adjacent DATE column showing a date to signify if training took place (by an X) and if so, the corresponding date that the training took place.
2v7v6t4.jpg



Currently, every time I have to add a new name to this worksheet, I have to copy an existing name/date column, paste it onto the end somewhere, then correct it with the new name and "X" 's and dates, and then cut-and-insert the that new person into the appropriate spot (alphabetically.)

Before (a year or so ago) I had it working so that this sort could be executed via a macro, but i lost all conditional formatting when I did it (so I abandoned that idea.)

Now, I am re-visiting this idea as I am going to have a macro that (1) clears the conditional formatting, (2) groups each name column and its corresponding date column together, (3) sorts all of those grouped columns alphabetically by the name, and then (4) copies the formatting and conditional formatting from 2 columns that were previously not cleared in step 1, and pastes that formatting to all the name/date collumns that were just sorted.
icon14.png

(at least that is my plan
icon6.png
lol )

If anyone has a better, simpler idea... I am all ears...
Please and Thank you for any/all help here.
 
Upvote 0
I think I will just drop off this thread. I could probably work something up, but it would take quite a while because I do not readily have the code in mind that would do what you want, and that means resarch, trial and error until I get it. That is more time than I like to spend on a thread. Sorry.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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