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.
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,848
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
 

Watch MrExcel Video

Forum statistics

Threads
1,108,808
Messages
5,524,995
Members
409,615
Latest member
papaluigi94

This Week's Hot Topics

Top