Macro to insert blank line with formula

S

Sharlene

I need a macro that will insert an extra blank line that includes a
*total* formula in the last column. Simple if u know how, im sure :)
Can anyone help me out plz?
 
B

Bernie Deitrick

Sharlene ,

Simple, if you explain it better. How is your data arranged? What do you
want to total? What is the logic for where to insert the blank line?

That said, below is one way, based on the current cell's current region.

HTH,
Bernie
MS Excel MVP

Sub SharleneInsert()
With ActiveCell.CurrentRegion
.Cells(.Rows.Count + 1, 1).EntireRow.Insert
.Cells(.Rows.Count + 1, .Columns.Count).Formula = _
"=SUM(" & .Columns(.Columns.Count).Cells.Address & ")"
End With
End Sub
 
D

Dave Peterson

You may want to look at Data|Subtotals.

This'll get you pretty close--but I wouldn't insert an extra row. Maybe just
doubling the row height of the subtotal rows would look nice enough.
 
Top