Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
Hi,
I have three columns of data and 100 rows, I want the 4th column to sum each row, the code I have is as follows: Think there is something wrong with my SUM Function Dim i, j For i = 1 To 100 Cells(i, 4) = Sum(Cells(i, 1), Cells(i,3)) End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
Hi
why do you want a macro for this and don't insert the formula in the cells directly and copy this formula. so something like =SUM(A1:C1) and copy this down "teresa" wrote: Hi, I have three columns of data and 100 rows, I want the 4th column to sum each row, the code I have is as follows: Think there is something wrong with my SUM Function Dim i, j For i = 1 To 100 Cells(i, 4) = Sum(Cells(i, 1), Cells(i,3)) End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
Hi,
Change it to following: For i = 1 To 100 Cells(i, 4) = Cells(i, 1) + Cells(i, 2) + Cells(i,3) You cant use that Sum function in VBA. Sharad *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
"Sharad" skrev i melding
... You cant use that Sum function in VBA. Hi Sharad Be very careful with "cant" when it comes to Excel / VBA. Sub Test() MsgBox Application.Sum(Range("A1:A10")) End Sub HTH. Best wishes Harald |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
SUM is a worksheetfunction, and you are trying to use it VBA. You can either
- use a straight worksheet function of SUM, no V BA - use a worksheetfunction in VBA - Cells(i, 4) = WorksheetFunction.SUM(Range("A"& i & ":C" & i)) - add in V BA - Cells(i, 4).Value = Cells(i, 1).Value + Cells(i,2).Value + Cells(i,3).Value -- HTH ------- Bob Phillips "teresa" wrote in message ... Hi, I have three columns of data and 100 rows, I want the 4th column to sum each row, the code I have is as follows: Think there is something wrong with my SUM Function Dim i, j For i = 1 To 100 Cells(i, 4) = Sum(Cells(i, 1), Cells(i,3)) End Sub |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Summing
Thanks Harald! *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
summing | Excel Discussion (Misc queries) | |||
summing | Excel Worksheet Functions | |||
PivotTable and summing/not summing | Excel Discussion (Misc queries) | |||
Summing | Excel Programming | |||
summing | Excel Programming |