Sorting Row-Paired Data (Macro?)

ForrestGump01

New Member
Joined
Mar 15, 2019
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I've got a very large data set (setup layout below), which I am trying to sort without disrupting the adjacent column references... Column "A" has the headers, while columns B+ have successive months worth of data (e.g. Jan, Feb, Mar, etc), however, the data is being sourced from two different places and being compared (testing for variance). I want to parse the two sources of data without losing the links/references in the adjacent columns, and because many of the links in those columns are not absolute, I cannot copy/paste, only cut. There are hundreds of accounts, each currently comprised of 2

Ex.
Account 001 - Source 1
Account 001 - Source 2
Account 002 - Source 1
Account 002 - Source 2
Account 003 - Source 1
Account 003 - source 2

I'm trying to split all source 1 and 2 rows apart, so it can look like this:

Account 001 - Source 1
Account 002 - Source 1
Account 003 - Source 1

Account 001 - Source 2
Account 002 - Source 2
Account 003 - Source 2

Right now I am relying on manually cutting, row by row, the entire row for each "account" source and pasting to a new range, but as you can imagine even using key commands, on a large data set this is taking a lot of time and is prone to manual error.

Any suggestions for accomplishing this task? Maybe a macro that loops?

Thank you in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This could be done with a macro, but would this manual approach be any use?

1. Use a vacant column (I have inserted a new column B) & insert a formula like my B2 and copy down.


Excel 2016
ABCDEFGH
1HeadersSourceJanFebMarAprMayJun
2Account 001 - Source 1Source 1165357579418
3Account 001 - Source 2Source 2288149605674
4Account 002 - Source 1Source 1151066679817
5Account 002 - Source 2Source 2808080808080
6Account 003 - Source 1Source 1824534203455
7Account 003 - source 2source 2487411389453
Sort
Cell Formulas
RangeFormula
B2=TRIM(REPLACE(A2,1,FIND("-",A2),""))



2. Now sort the whole table based on that new column.


Excel 2016
ABCDEFGH
1HeadersSourceJanFebMarAprMayJun
2Account 001 - Source 1Source 1165357579418
3Account 002 - Source 1Source 1151066679817
4Account 003 - Source 1Source 1824534203455
5Account 001 - Source 2Source 2288149605674
6Account 002 - Source 2Source 2808080808080
7Account 003 - source 2source 2487411389453
Sort


3. Then, if you still need to physically separate the the two groups, cut and paste the second group.
 
Upvote 0
This could be done with a macro, but would this manual approach be any use?

1. Use a vacant column (I have inserted a new column B) & insert a formula like my B2 and copy down.

Excel 2016
ABCDEFGH
1HeadersSourceJanFebMarAprMayJun
2Account 001 - Source 1Source 1165357579418
3Account 001 - Source 2Source 2288149605674
4Account 002 - Source 1Source 1151066679817
5Account 002 - Source 2Source 2808080808080
6Account 003 - Source 1Source 1824534203455
7Account 003 - source 2source 2487411389453

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sort

Worksheet Formulas
CellFormula
B2=TRIM(REPLACE(A2,1,FIND("-",A2),""))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>




2. Now sort the whole table based on that new column.

Excel 2016
ABCDEFGH
1HeadersSourceJanFebMarAprMayJun
2Account 001 - Source 1Source 1165357579418
3Account 002 - Source 1Source 1151066679817
4Account 003 - Source 1Source 1824534203455
5Account 001 - Source 2Source 2288149605674
6Account 002 - Source 2Source 2808080808080
7Account 003 - source 2source 2487411389453

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sort



3. Then, if you still need to physically separate the the two groups, cut and paste the second group.

Hi Peter,

Thank you for the reply. I wound up doing something similar to this. However, was unable to sort the data by the grouping due to relative references in the subsequent columns (e.g. Account 12345 source 2 might be referencing Account 98765 source 2 located in row 105 without absolute references, so when I would resort the data it would not maintain the proper relative linking). I've already finished manually cut/pasting the data (I used sort/filter to sort by "Source 1", cut/pasted them all individually into a new range, and then using a macro deleted all the newly created blank rows in the remaining "Source 2" range...
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

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