Columns(2)

MJA

Board Regular
Joined
Feb 18, 2002
Messages
79
Hello again,

I have 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
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If you're trying to add some specific columns, try this:

Sub Test()
StartCol = 1 'This is Column A
EndCol = 3 'This is Column C
FormCol = 4 'This is Column D
Counter = 0
For x = StartCol to EndCol
Counter = Counter + 1
Cells(Counter, FormCol).Formula = "=SUM(" & Columns(x).Address & ")"
Next x
End Sub
 
Upvote 0
On 2002-02-20 05:58, Juan Pablo G. wrote:
If you're trying to add some specific columns, try this:

Sub Test()
StartCol = 1 'This is Column A
EndCol = 3 'This is Column C
FormCol = 4 'This is Column D
Counter = 0
For x = StartCol to EndCol
Counter = Counter + 1
Cells(Counter, FormCol).Formula = "=SUM(" & Columns(x).Address & ")"
Next x
End Sub

THANK YOU THANK YOU THANK YOU
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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