![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 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 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Georgia USA
Posts: 544
|
why not just use =SUM(A:A),=SUM(B:B),=SUM(C:C)
|
|
|
|
|
|
#3 | |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Quote:
Because the columns can vary! |
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
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 |
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Feb 2002
Location: Hengelo
Posts: 79
|
Quote:
__________________
Best regards, Martin J.A. Maatman Oonk |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|