VBA copy sequence minus one and paste, loop?

ruannpreger

New Member
Joined
Sep 25, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to figure out on how to copy a 'range'/'list' in column A to the next column B and then copy the same range/list A minus one selection to the end of column B (after the first copy) and so on , until the range in A is finished/ has reached its end.

example
Col A
15901
14901
22001
21200

VBA should copy 14901, 22001, 21200 and paste (vertically) that in Col B, then copy 22001,21200 to Col B under the previous paste. And then copy 21200 and paste to Col B. The list would then be:
14901
22001
21200
22001
21200
21200

It all should happen just in one sheet, in the end to generate a list (the actual list is over 100 codes long)
Any help on this is highly appreciated.
thanks.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Give this macro a try...
VBA Code:
Sub Test()
  Range("A2", Cells(Rows.Count, "A").End(xlUp)).Copy Range("D1")
  Range("B2", Cells(Rows.Count, "B").End(xlUp)).Copy Cells(Rows.Count, "D").End(xlUp).Offset(1)
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
How about
VBA Code:
Sub ruannpreger()
   Dim i As Long
   Dim Rng As Range
   
   Application.ScreenUpdating = False
   Set Rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
   For i = 1 To Rng.Rows.Count - 1
      Rng.Offset(i).Copy Range("B" & Rows.Count).End(xlUp).Offset(1)
   Next i
End Sub
 
Upvote 0
Thanks for the prompt replies! incredible.
The suggestion from Fluff worked for me.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Hi Rick, i have tried it. However it did copy but it was missing a 'loop' to repeat the sequence.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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