Columns

MJA

Board Regular
Joined
Feb 18, 2002
Messages
79
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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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
 
Upvote 0
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)"

I hope I could help you,
Pierre
This message was edited by paludgnp on 2002-02-19 06:17
 
Upvote 0
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.
 
Upvote 0
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)"

I hope I could help you,
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,550
Messages
6,114,265
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top