Copy Row 2 and insert x number of times

simmerer

New Member
Joined
Sep 6, 2017
Messages
33
I have a spreadsheet which is reused every month. The "PS" sheet contains a variable number of rows determined by the monthly raw data that will be inserted. The actual data is copied from one workbook to the PS sheet, with formulas interspersed on each row in several columns. Each month I delete the old data, retain the formulas in row 2, and then copy row 2 to how many rows the new data needs; usually around 1500.

To automate this I want to first show an input box where I can state how many rows are needed. Then insert the copied row into the range. I see two ways to perform this, but part of each is eluding me. The insert shift.xldown seems to be the fastest. The loop would be the second choice.

I have this:

Sub Macro1()
'
' Macro1 Macro

Dim x As Integer

Sheets("PS").Select
x = InputBox("How Many Rows of Raw Data?", "Add Rows")
'
'
Rows("2:2").Select
Selection.Copy
'Here is where I get lost
Rows("3:" & X).Select or maybe Range("A3:A" & X).Selection.Insert Shift:=xlDown


End Sub


This should be easy, but I am not getting it.

Help! any suggestions?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi & welcome to MrExcel
How about
Code:
Range("A3").Resize(x).EntireRow.Insert
Range("A2").Resize(x + 1).EntireRow.FillDown
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
Members
453,020
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