Sum to active cell

  • Thread starter Thread starter GregR
  • Start date Start date
G

GregR

I have a macro, where I am trying to do a sum from row 5 to the active cell.
How do I designate the range. Here is what I have;

Activecell.formula="sum(range(cell(5,0),cell(activecell,0))", but it gives
me a compile error. TIA

Greg
 
Greg
One way:
ActiveCell.Value=Application.Sum(Range(Cells(5,ActiveCell.Column),(Cells(ActiveCell.Row-1,ActiveCell.Column)).
HTH Otto
 
Activecell.formula="=SUM(" & Cells(5,Activecell.Column).Address & ":" &
Activecell.Offset(-1,0).Address & ")"

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
One way:

With ActiveCell
.Formula = "=SUM(" & Range(Cells(5, .Column), _
Cells(.Row - 1, .Column)).Address & ")"
End With

You can't sum the activecell too, without causing a circular reference,
so I assumed you wanted to sum to the row before.
 

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

Similar Threads

Active cell 4
Macro sum 1
Summing rows using formulas with variables 1
Excel Macro to use cells as a autofilter 0
Insert a Row and then Sum 1
Macro-active cell 3
Sum Formula with variable range 2
Sum column with count formula 1

Back
Top