Cutting and Pasting Rows Based on a Matching Criteria

LukeAJN

New Member
Joined
Feb 7, 2022
Messages
11
Hi All

I have a particular problem here that I am wondering if anyone can figure out the best way to go about it. I currently have a spreadsheet with a jumbled and out of order list of values in a certain column. I need to be able to search the spreadsheet, find the two corresponding entries, and then cut and paste them so that they are in rows next to each other. The data is already sorted largest to smallest so when cutting a row it must always best inserted below the corresponding entries.


A small visualization of this would be like the below




COL B
X1
Y2
Z1
Y1
Z2
X2

This would then become


COL B
X1
X2
Y2
Y1
Z1
X2
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Are the values in column B as simple as the ones you used in your example. That is could the search be done only on the first letter of the value in Column B?
 
Upvote 0
No unfortunately not, in reality they are a number about 8 digits long, I just simplified it to make the code easier in this example. I should be able to manipulate it to give me what I want though
 
Upvote 0
So,
No unfortunately not, in reality they are a number about 8 digits long, I just simplified it to make the code easier in this example. I should be able to manipulate it to give me what I want though
you need to define “corresponding” will the values always be [A-Z]*nnnnn? (Letters before a numeric value?)
 
Upvote 0
So,

you need to define “corresponding” will the values always be [A-Z]*nnnnn? (Letters before a numeric value?)
In the actual excel there are no letters. 43277679 will always be matched with 00100345, 43780097 will always be match with 43226788 etc
 
Upvote 0
In the actual excel there are no letters. 43277679 will always be matched with 00100345, 43780097 will always be match with 43226788 etc
This is even more unclear ...
Can you you send a mini-sheet (XL2BB) with some of your sample data?
 
Upvote 0
Yes I will try send it later when I get home, I can't use that add on with my work PC. In reality these are account numbers, and every account has one opposite account. Think about how someone will have a personal/checking account and also a saving account with the same bank. The account numbers would be different but they need to be mapped together. I understand it is more complicated expressed this way, which is why in my first example I expressed it where the Xs get matched together, as do the Ys etc
 
Upvote 0
which is why in my first example I expressed it where the Xs get matched together, as do the Ys etc
Except that it was Z1 and X2 at the end. :confused:

1691660710993.png
 
Upvote 0
If your worksheet is sorted and the values are always paired together what is left to be done? I would think a sort on two columns would yield your desired results.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

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