help with sum macro - different number of rows

M

malewine

I am trying to record a macro that would sum a column at the end of the
column. However the number of rows will not always be the same. How
do I get the sum to always show up at the end of the column.

TIA
Mark
 
D

Dave Peterson

dim NextRow as long
with activesheet
Nextrow = .cells(.rows.count,"A").end(xlup).row + 1
.cells(nextrow,"A").formulaR1C1 = "=sum(r1c:r[-1]c)"
end with

This will sum from: R1C (R1 of the same Column)
to: R[-1]C (one row up of the same column)
 
S

Stopher

This will select all the rows of a particular coulmn, in this case the
starting cell is "A3"

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select

Just do a sum on this selection and output it to a cell. Hope this
helps.
 
Top