Thanks:  0
Likes:  0

1. Hello,

I want to total different columns.
But I can't figure out the right code.

For b = 1 To 15
Cells(b, 16).FormulaR1C1 = "=SUM(C & b)"
Next

This doesn't work.
Who can help me!?

Martin

2. On 2002-02-19 05:53, MJA wrote:
Hello,

I want to total different columns.
But I can't figure out the right code.

For b = 1 To 15
Cells(b, 16).FormulaR1C1 = "=SUM(C & b)"
Next

This doesn't work.
Who can help me!?

Martin
Try with

Cells(b, 16).FormulaR1C1 = "=SUM(C" & b

But, why use SUM ? that's only one cell, you could just use:

Cells(b, 16).FormulaR1C1 = "=C" & b

3. Hello Martin,

Answering you would be easy if you could explain better what you exactly want.

Do you want to sum the columns from 1 to 15 in the 16th column in row i?
If yes, check the two codes below:

For b=1 to 15
cells(i,16)=cells(i,16)+cells(i,b)
next b

OR

Cells(i, 16).FormulaR1C1 = "=SUM(C1:C15)"

Pierre

[ This Message was edited by: paludgnp on 2002-02-19 06:17 ]

4. On 2002-02-19 05:59, Juan Pablo G. wrote:

Try with

Cells(b, 16).FormulaR1C1 = "=SUM(C" & b

But, why use SUM ? that's only one cell, you could just use:

Cells(b, 16).FormulaR1C1 = "=C" & b
Wait a sec... just spotted an error in my code. Try this instead.

Cells(b, 16).FormulaR1C1 = "=SUM(C" & b & ")"

I still don't understand why you need SUM, but this should work.

5. On 2002-02-19 06:00, paludgnp wrote:
Hello Martin,

Answering you would be easy if you could explain better what you exactly want.

Do you want to sum the columns from 1 to 15 in the 16th column in row i?
If yes, check the two codes below:

For b=1 to 15
cells(i,16)=cells(i,16)+cells(i,b)
next b

OR

Cells(i, 16).FormulaR1C1 = "=SUM(C1:C15)"

Pierre

[ This Message was edited by: paludgnp on 2002-02-19 06:17 ]
Hello again,

I have say three columns(A, B, C) there is a serie of numbers in each column. I want the total of each column in cells D1, D2 and D3.

Sub Test()
For x = 1 To 3
Cells(x, 4).FormulaR1C1 = "=SUM(C" & x & ")"
Next
End Sub

The macro above can't do the trick.
WHY?!?!

Best regards,

Martin

6. On 2002-02-20 05:46, Juan Pablo G. wrote:
Why ? well, because you're only summing column C, not A:C, change it to this:
Code:
Sub Test()
For x = 1 To 3
Cells(x, 4).Formula = "=SUM(A" & x & ":C" & x & ")
Next
End Sub
Also, you were mixing two range types, R1C1 with A1 style. This should do the trick.
C stands for column and then a 1 or 2 or 3 for column A, column B, column C.

In cell D1 stands the total of column1 = column A

In cell D2 stands the total of column2 = column B

In cell D3 stands the total of column3 = column C

## User Tag List

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•