Copy rows down including all formats depending on a Cell number

tyrese215

New Member
Joined
Feb 25, 2009
Messages
33
Hi all,

I have a template that needs to be filled out by my client. Rather than pre-populating a worksheet with say 500 rows (which increases size of file), I want the user to enter how many records they need to fill in Cell A1, and then the code will copy the entire row in row 8, including all my formats, formulas down the page corresponding to the value in cell a1, just as if the user would copy each row down himself.

All rows that are copied down must have dynamic references, ie they need to be copied down.. just as if you were to use the fill handle when you put the cursor on the bottom right of a cell.


Secondly, I need some code that will automatically number cells A8, with 1, down to what ever number of records the user would like to generate which is the cell value in A1. So if the user enters 50 is cell A1, then cell A8, must say 1, A9 must say 2, A10 must say 3 all the way down to 50.

Please ensure that the formats and the cell colours used in row 8 are copied down as well corresponding to the value in cell 8..

Please help asap. I have this project due shortly..

Cheers and many thankyous....
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Not convinced that I understand your formatting requirements but try this for starters

Sub Expand_Template()
Dim No_Of_Rows As Integer
No_Of_Rows = Cells(1, 1).Value
Range(Cells(8, 2), Cells(8, 10)).AutoFill Destination:=Range(Cells(8, 2), Cells(No_Of_Rows + 7, 10)), Type:=xlFillDefault
Cells(8, 1).Value = 1
Cells(9, 1).Value = 2
Range(Cells(8, 1), Cells(9, 1)).Select
Selection.AutoFill Destination:=Range(Cells(8, 1), Cells(No_Of_Rows + 7, 1)), Type:=xlFillDefault
Range("A1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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