Inserting rows below and copying down the formula

Hagrid1

New Member
Joined
May 5, 2016
Messages
13
Hi Folks,

I'm quite a novice at VBA and would like a macro to insert a Row(s) at the bottom of a table and copy the formula so that it pulls throw the information form another sheet within the workbook

e.g.

Rows 2 to 5 have completed data
Rows 6 to 10 are blank of data but have the equation to pull through form a specific cell on other sheets

Column A Column B
=IF(Index_page!C60="","",Index_page!C60) (This cell will be completed with text)=IF(Index_page!D60="","",Index_page!D60) (This cell will be completed with text)
=IF(Index_page!C61="","",Index_page!C61) (This cell will be Blank without text)=IF(Index_page!D61="","",Index_page!D61) (This cell will be Blank without text)
This cell will be selected to start the macro

<tbody>
</tbody>


I would like the last cell to be selected and when the MACRO button is clicked then X number of cells will be entered above with the formulae being drawn down so that it reflects the next set of data form the index page

I have tried to auto right a MACRO but it always goes to the cell range originally selected which puts the equation out of coulter, I would also like the MACRO to ask how many lines you would like to insert

Thanking you all in advance

Hagrid1

<tbody>
</tbody><colgroup><col><col></colgroup>
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi Folks I have the following code which seems to work but would appreciate if someone could tidy it up and include VBA around setting the pop up for number of rows to be entered.

Sub Insertrowsv2()
Dim row As Integer
Dim row2 As Integer
Dim i As Integer
row = lastrow
row2 = row - 1
For i = 1 To 3
Rows(row2).Select
Selection.Copy
row = lastrow
Rows(row).Insert xlShiftDown
Next
End Sub
Public Function lastrow() As Long
lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row + 1

End Function


Thanking you in advance

Hagrid1
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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