VBA Repeat cells

grifdoogindoggy

New Member
Joined
Aug 27, 2019
Messages
21
How would I turn:

A1
A2
A3

Into:

A1
A2
A3
A1
A2
A3

as many times as I want into a different sheet?
 
Last edited:

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe something like this.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub
 
Upvote 0
Maybe something like this.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub

Thank you! This works well, but for some reason this is printing into the A2 cell and not the A1?
 
Upvote 0
This should do it.

Code:
Sub Repeat()
Dim wm As Worksheet: Set wm = Sheets("Sheet1") 'Main Sheet
Dim wn As Worksheet: Set wn = Sheets("Sheet2") 'Sheet to copy to
Dim Times As Long: Times = 5
Dim LR As Long
Dim AR() As Variant: AR = wm.Range("A1:A" & wm.Range("A" & Rows.Count).End(xlUp).Row).Value


For i = 1 To Times
    If i = 1 Then
        LR = wn.Range("A" & Rows.Count).End(xlUp).Row
    Else
        LR = wn.Range("A" & Rows.Count).End(xlUp).Row + 1
    End If
    wn.Range("A" & LR).Resize(UBound(AR), 1).Value = AR
Next i


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,484
Members
448,967
Latest member
visheshkotha

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