Rearrange entire row based on consecutive duplicates

sshugar

New Member
Joined
Oct 18, 2013
Messages
5
Please help me with below issue. I have SAP table dump and would like to rearrange the entire table based on a column C(Batch). Condition is that the batch in consecutive row cells are not duplicates(example C1<>C2,C2<>C3...etc.,) . You'r time and help is really appreciated. I'm struggling with this issue for long time and it takes up 40% of my work hours.Please help ..Thank you!


The logic: Start with C2
Check C2 = C3? if yes then move C3 down to C4 and move C4 up to C3 location then compare C2 = C4?repeat till C2 is not same as whatever is the current C3 value for iteration and it should repeat this for all rows till end.
Please feel free to use any other logic that works more efficiently than mine.

PS: No blank batch cells are present. 70% of data is unique batch.

**BEFORE:**


Plnt| Material | Batch (Column C)
1074 10130566 ABC123
1074 10130566 ABC123
1074 10130566 ABC123
1076 10196975 DEF456
1076 10196975 DEF456
1078 10196977 GHI789
1076 10196975 DEF456
1078 10196977 GHI789
1076 10196975 DEF456


**AFTER:**



Plnt| Material | Batch (Column C)
1074 10130566 ABC123
1076 10196975 DEF456
1074 10130566 ABC123
1076 10196975 DEF456
1074 10130566 ABC123
1078 10196977 GHI789
1076 10196975 DEF456
1078 10196977 GHI789
1076 10196975 DEF456
 
Last edited:

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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