Inserting rows w/formulas


Posted by Eric Sustaita on August 03, 2000 10:37 AM

I am constructing a expense spreadsheet. It is broken up by months. I need to be able to insert rows in various months. However when I insert the rows I would like the formulas to also be automaticly be inserted also. Is there a way to do that?

thanks
Eric

Posted by Celia on August 03, 0100 5:53 PM

Eric
Try this :-

Sub InsertRow()
Application.ScreenUpdating = False
Dim cell As Range
Selection.EntireRow.Insert
For Each cell In Intersect(ActiveSheet.UsedRange, Selection.Offset(-1, 0).EntireRow)
If cell.HasFormula Then
cell.Copy cell.Offset(1, 0)
End If
Next
End Sub

Celia




Posted by Celia on August 03, 0100 5:56 PM

Post script

Eric
Try this :-

Sub InsertRow()
Application.ScreenUpdating = False
Dim cell As Range
Selection.EntireRow.Insert
For Each cell In Intersect(ActiveSheet.UsedRange, Selection.Offset(-1, 0).EntireRow)
If cell.HasFormula Then
cell.Copy cell.Offset(1, 0)
End If
Next
End Sub

Celia

The macro inserts a row above the selected cell or row, and copies the formulas from the row above.

Celia