Copy row and paste down N times

triumpht100

New Member
Joined
Dec 5, 2013
Messages
3
Hi everyone, new to the forums here and failry green working with VBA in Excel (no formal training). I'm trying to do what I think should be fairly simple but after all my searching, I can't find exactly what I need.

Here's what I'm working with:

- I have data with formulas in row 3 of Sheets.("upload")
- I need to copy that entire row and paste it down with formulas n - 1 times starting with row 4 (row 3 remains as is).
- n = value in cell A1

I appreciate any help...thanks in advance!
 
Last edited:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try:
Code:
Sub copyRows()
    Application.ScreenUpdating = False
    Dim x As Long
    Dim y As Long
    y = 1
    Rows(3).Copy
    For x = 1 To Cells(1, 1).Value - 1
        Rows(3 + y).PasteSpecial xlPasteFormulas
        y = y + 1
    Next x
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Wow! Mumps, that's what I call service! Seriously, thank you. It works beautifully. The only thing I made an adjustment for was the n count, for some reason the - 1 portion didn't work (it still copied it down n times instead of n - 1) so I applied the - 1 to the value that gets populated in cell A1.

I'm convinced that I need to take some VBA courses, this stuff is beyond useful. Thanks again!

Xavier
 
Upvote 0
BTW - thought you should know that it was my mistake when copying over your code, I noticed that I dropped off the -1. So your code in fact worked 100% perfectly! Thanks!
 
Upvote 0
Thank you for the feedback. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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