Summing using a macro

  • Thread starter Thread starter James
  • Start date Start date
J

James

I have written a macro to separate a large data set into
discrete sections. these sections vary from 2 to 50 rows.
I want to sum the values for each section.

I know the start / end / row numbers (in R1C1 format) but
don't know how to code the sum command: any ideas?
 
James,

If you know the cell where you want the formula, then code like this:

Cells(myRow, myColumn).Formula = _
"=SUM(" & Range(Cells(RowStart, Col), _
Cells(RowEnd,Col)).Address & ")"

Where myRow, myColumn, RowStart, RowEnd, and Col are all variables
with valid values.

HTH,
Bernie
MS Excel MVP
 
Back
Top