Summing
Thanks!
-----Original Message-----
Hi Kevin,
Try:
Sub Atester04a()
Dim rng As Range
Dim myRes As Double
Dim i As Long, j As Long, k As Long
i = 2: j = 4: k = 1
Set rng = Range(Cells(i, k), Cells(j, k))
MsgBox rng.Address
myRes = Application.Sum(rng)
MsgBox myRes
End Sub
---
Regards,
Norman
"Kevin" wrote in
message
...
Thanks for responding. I use the cells construct
because
I am actually doing this for more than one 1 column
and I
have to do it dynamically because the number of columns
needing summing is not fixed. I actually am using
variables to represent the appropriate cell
coordinates.
Thanks!
Kevin
-----Original Message-----
Hi Kevin.
Sub Atester04()
Dim rng As Range
Dim myRes As Double
Set rng = Range("A2:A4")
myRes = Application.Sum(rng)
MsgBox myRes
End Sub
---
Regards,
Norman
"Kevin" wrote in
message
.. .
How can I sum a range of cells in code. I have tried
myresult=Application.worksheetfunction.sum(Range
(cells
(2,1),cells(4,1))
but am having trouble. I get a syntax error.
Thanks!
Kevin
.
.
|