Repeat cutting and pasting to the row below

Closed
Amit - Mar 11, 2010 at 12:39 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Mar 11, 2010 at 02:05 PM
Hello,
I am trying to create a macro loop that cut every row at the D column and paste it to the next row starting at the A column, until there is no more data on the D column. The following is the backbone of my macro, they are not functional, the underlined ones are what I would like to be replaced by actual correct coding.

Sub Cut_Paste()

Dim n as Integer

Loop n = 1, infinity

Range("D .n").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Cut
Range("A .(n+2)").Select
ActiveSheet.Paste

Loop Until if D .(n+2) == empty cell

End Sub

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 11, 2010 at 02:05 PM
If you want to just copy whole D to A and just move it one cell down, why this loop. I am sure I am missing some thing here

Any how, this will give you last used cell in D column
lastRowD = Cells(ActiveSheet.Rows.Count, "D").End(xlUp).Row
1