Summation problem with Range

  • Thread starter Thread starter jesmin
  • Start date Start date
J

jesmin

Hi Anyone:
I am working in an Excel sheet. I am having trouble to generalize a
summation with the use of Range.
The code that I was using and having an error.

Sheets("Sheet1").Range("D6:G6,D10:G10").FormulaR1C1="=R[-3]C+R[-1]C"

EXAMPLE:
ROWNUM---D---E---F---G
1-----------10--20--10--40
2-----------15--30--10--10
4-----------10--10--30--40
5-----------20--20--40--10
6-----------*35--50--50--20 *
7-----------10--20--30--40
8-----------10--20--30--40
9-----------20--10--40--10
10----------*30--30--70--50 *
--The sum is not accurate and showing some error for recursive
reference. I have no clue. Looking forward for any help with much
appreciation.
 
The ranges are a different number of rows and I assume you want to SUM them
(all rows). Row 3 was missing from your example:

Sheets("Sheet1").Range("D6:G6").FormulaR1C1 = "=sum(R[-5]C:R[-1]C)"

Sheets("Sheet1").Range("D10:G10").FormulaR1C1 = "=sum(R[-3]C:R[-1]C)"

HTH
 
Back
Top