Copy Formula When Adding Rows With Macro

angusfire

New Member
Joined
Feb 24, 2012
Messages
34
I have a macro that add rows to a range. The new rows copy the formula from the row above correctly except for the first column. Any suggestions?

VBA Code:
    m = Range("Add_Months").Value
    Application.CutCopyMode = False
    Rows(Range("Date_List").Rows.Count + Range("Date_List").Cells(0, 1).Row - 1).EntireRow.Select
    Rows(Selection.Row).Copy
    Rows(Selection.Row).Resize(m).EntireRow.Insert Shift:=xlDown
    Application.CutCopyMode = True
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
you can check row before action you perform.


VBA Code:
Dim lstRow as long


'''to find out last used row in column A
lstrow =  worksheets("Date_List").cells(rows.count,"A").end(xlup).row


''''check if it is not first Row
if lstrow  <> 1 then


''''Perform action here"

Else
 Msgbox "No Data Available, just Header"

End if
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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