Insert a row

APVR

New Member
Joined
Mar 15, 2011
Messages
11
How to insert a row and the protect formulae above is copied down.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,896
There is no worksheet event that can trigger when a row is inserted, so you would have to code a procedure that a user could run to insert a row and copy formulas.

What version of Excel are you using?
What columns contain the formulas?
By protected formulae, I assume you mean the worksheets has protection turned on. Is the protection password protected?

This code should work, althought it might require some modification based on your version of Excel and protection options you have set.

Code:
Sub InsertNewRowWithFormulas()
 
    ActiveSheet.Unprotect
    With Rows(Selection.Row)
        .Copy 'copies the row that contains the upper left cell of the selection
        .Offset(1, 0).Insert Shift:=xlDown
        .Offset(1, 0).SpecialCells(xlCellTypeConstants, 23).ClearContents 'Clear constants in new row
        .Offset(1, 0).Select
    End With
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True 'XL 2007 default worksheet protection
 
End Sub
 

APVR

New Member
Joined
Mar 15, 2011
Messages
11
Excel 2010
Columns D & E
Yes the sheet is protect.

Thanks for the code
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,029
Messages
5,856,933
Members
431,840
Latest member
simplysoph

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
Top