Need to insert rows with formulas

sachi1982

New Member
Joined
May 14, 2015
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi All,

In my work sheet i need to add 100 rows with formulas.

for eg. i want to insert 100 rows from row 300 and i want to those 100 rows to inherit row 299 formulas. this template got columns from A to Q and need to copy down all these formulas.

Could you kindly help. I have very limited knowledge in macros. so appreciate if you can give me the whole code.

cheers,
S
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
If there is nothing beyond Col Q then we can simply select the Row 299 and copy that down the range of rows 300:400 (maybe I should have stopped at 399).
Try this:
Code:
Sub Multi_Rows()
'
' Multi_Rows Macro
'

'

    Rows("299:299").Select
    Application.CutCopyMode = False
    Selection.Copy
    Rows("300:400").Select
    ActiveSheet.Paste
    
End Sub
 
Upvote 0
Don't see why you need VBA or anything else fancy for this.

You could either convert to a Table, or just highlight the last row with formulas, and either dbl-click the fill handle, or just drag down
 
Upvote 0
Thanks BrianJN1.

However, i need to insert the 100 rows as well. so i need to do 2 things and this need to be repeated if needed.
1. add 100 rows to the worksheet
2.copy all the formals for those inserted rows.

i am going to add a button to execute this, so that if i need more rows each time i can press this button and get 100 rows each time.

please help .


 
Upvote 0
Maybe
Code:
Sub sachi1982
With Range("A300:Q300")
    .AutoFill Destination:=.Resize(100), Type:=xlFillCopy    '<-----Change the 100 to whatever you want/need
End With
End Sub

Note that the to be copied Range is hard coded. If that needs changing, let us know.
 
Upvote 0
I take then that we are going to have to provide an insertion point, eg, At Row 100, 250, ...
Are you always going to need to insert 100 rows? We could take that into account at the same time.
 
Upvote 0
With this you should be able to keep on clicking until you run out of rows.
Code:
Sub From_Last_Used_Row()
Dim lr As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
With Range(Cells(lr, 1), Cells(lr, 17))
    .AutoFill Destination:=.Resize(100), Type:=xlFillCopy    '<-----Change the 100 to whatever you want/need
End With
End Sub

Or, as Brian suggested
Code:
Sub From_Last_Used_Row_A()
Dim lr As Long, a As Long
lr = Cells(Rows.Count, 1).End(xlUp).Row
a = InputBox("How many extra rows do you want filled?", "Rows to fill with formulae")
With Range(Cells(lr, 1), Cells(lr, 17))
    .AutoFill Destination:=.Resize(a + 1), Type:=xlFillCopy
End With
End Sub
 
Last edited:
Upvote 0
ooh thank you so much. one small problem. it looks like it is copying down what ever in the last used row. i got one column that got manual input. so is it possible to copy down only the formulas.
again this is so much help. Thanks again.
 
Upvote 0
Sachi,
I am giving you a code which does as I offered. You get two message boxes. The first asks for the insertion point, eg row 3, and then How many rows to insert, eg 10.
The macro selects Row 2 and copies it. It then selects and pastes from Row 3 for the next 10 rows.
Code:
Sub Insert_rows()
Dim StartAt As Long
Dim Many_Rw As Long
StartAt = InputBox("Insert at Row:")
Many_Rw = InputBox("How many rows:")

Rows(StartAt - 1 & ":" & StartAt - 1).Copy
Rows(StartAt & ":" & StartAt + Many_Rw).Select
    Selection.Insert Shift:=xlDown
    ActiveSheet.Paste

End Sub
Any problems with this?

Ah! I just saw your reply above. What column(s) do you NOT want formulae? That can be arranged in either my code or jolivanes.
 
Last edited:
Upvote 0
You should have mentioned all of this in your first post so people don't waste time on code that is not what is required.
Read your last post again and see if there is anything in it that should be explained. Hint" "I got one column that got manual input"
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,208
Members
448,874
Latest member
Lancelots

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