MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Inserting a row


Posted by Rayn on April 30, 2001 9:23 PM


Hi

I would like to insert a row using a macro.
i would like the row inserted. and formulas copied from the above row

Can anyone Help me ?
Thank you!!!


Posted by Dave Hawley on May 01, 2001 2:28 AM


Hi Ryan

The first code will insert a new row where the activecell is and place in the SAME formulas as above, regardless of whether the are relative or not. The second will do the same except if the formulas are relative then will change accordingly.


Sub TryThis()
ActiveCell.EntireRow.Insert
ActiveCell.EntireRow = _
ActiveCell.EntireRow.Offset(-1, 0).Formula
End Sub

Sub TryThis2()
ActiveCell.EntireRow.Insert
ActiveCell.EntireRow.Offset(-1, 0).Copy
ActiveCell.EntireRow.PasteSpecial (xlPasteFormulas)
Application.CutCopyMode = False
End Sub

Dave
OzGrid Business Applications

Posted by Rayn on May 01, 2001 5:25 AM


Thanks a great deal!!!!!!!!!!!!!