Macro to insert blank line with formula

  • Thread starter Thread starter Sharlene
  • Start date Start date
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?
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top