Swap rows of columns: "R", "S" and "T"

harzer

Board Regular
Joined
Dec 15, 2021
Messages
122
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone,
I need your help.
The range we will work on is the range: ("R2:T" & Last line).
This range is quite large, which is why I allow myself to ask you for a fairly fast loop, like (UBound) or (Dictionary).
The purpose of my request is to swap the rows of columns: "R", "S" and "T", I will explain the procedure later.
The initial table looks like this:

Classeur1
RST
1JeunePèreMère
2876-054/2004 FB1C1
3876-025/2006 FB2C2
4GUP14-028/2006 FB3C3
5GUP14-041/2006 MB4C4
6GUP14-011/2007 FB5C5
7AMA55-014/2007 MB6C6
Feuil1


This is what I want to do, is to create a loop that will swap all the cells of the 3rd line "R3", "S3" and "T3" with all the cells of the 2nd line: "R2 ", "S2" and "T2". Then we display a Msgbox with the number of the passage of the loop.
Here is the result of the first pass of the loop:

Classeur1
RST
1JeunePèreMère
2876-025/2006 FB2C2
3876-054/2004 FB1C1
4GUP14-028/2006 FB3C3
5GUP14-041/2006 MB4C4
6GUP14-011/2007 FB5C5
7AMA55-014/2007 MB6C6
Feuil1



On the second pass of the loop, we will swap all the cells of the fourth line "R4", "S4" and "T4" with all the cells of the 2nd line: "R2", "S2" and " T2". Then we display a Msgbox with the number of the passage of the loop
Here is the result on the second pass of the loop:

Classeur1
RST
1JeunePèreMère
2GUP14-028/2006 FB3C3
3876-054/2004 FB1C1
4876-025/2006 FB2C2
5GUP14-041/2006 MB4C4
6GUP14-011/2007 FB5C5
7AMA55-014/2007 MB6C6
Feuil1


And so on until the last line of the range.
I remain at your disposal for any additional information.
Cheers.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,
My understanding is that, in the final run, after all the "swaps" you will be re-building a Sort in descending order ...
Am I missing something ?
 
Upvote 0
Good evening,
Thanks for your feedback,
No, this is not a sorting that I wish to do.
By the way, it's a little complicated to explain, basically, each time the loop passes, I have to put a code (instead of the Msgbox), which will retrieve values from other columns according to precisely the value of cell "R2".
I hope I expressed myself well.
Good for you.
 
Upvote 0

Forum statistics

Threads
1,215,231
Messages
6,123,754
Members
449,119
Latest member
moudenourd

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