Macro for New Line and Continued Formulas

Whylucky

New Member
Joined
Sep 24, 2013
Messages
39
Hey Guys,

So I am trying to get a macro that can create a new line below a selected cell and move the formulas down with it? The formulas are in cells AG:AP and i would like them to fill in the new created line. Is this possible? I have been looking around and it seems like it is hardcoded to certain cells. Thanks in advance your help is always greatly appreciated.
 
Hi

Please test this; note that if you write your formulas like
=SUM(d4:g6)

When dragging, cell references will change; but if the formula is like
=SUM($d$4:$g$6)

Cell references remain the same when dragging.

Code:
Sub NewLine_Formulas()


Dim r%
' inserts row below active cell
' drags formulas down


ActiveCell.Offset(1).EntireRow.Insert
r = ActiveCell.Row
Range("ag" & r & ":ap" & r).AutoFill Range("ag" & r & ":ap" & (r + 1)), 0


End Sub
 
Upvote 0

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