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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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