Copy and paste selected cells a given number of times

Report
-
ac3mark
Posts
13031
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
October 11, 2019
-
Hello,

I had a quick course on macro and I would like to write my first one, but I would need some help with it.

Id like a macro which copies the selected cells to a new worksheet. Id like it to copy under each other as many times, as the user gives in a msgbox.

So far I am at this stage, but cant figure out how to copy them under each other:

Sub Copy_Paste()
' Copy_Paste Macro
Dim i As Integer
Dim j As Integer

Selection.Copy

i = InputBox("Enter number copies to insert", "Paste")

Sheets.Add After:=ActiveSheet
For j = 1 To i
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Select
Next j

Last: Exit Sub

End Sub


Thanks a lot for the help in advance,

A

2 replies

Posts
13031
Registration date
Monday June 3, 2013
Status
Moderator
Last seen
October 11, 2019
1576
Offset by your loop counter 'j'.