calculating the sum of a range

T

T. S.

Hi.
I am trying to calculate the sum of a range.
In a sheet I'd just select some cell and type "=SUM(a3:a15)".
But I am trying to do this in a makro and its crucial that I do not
manipulate the sheet.
So I need to call a function - that is available from within a cell -
from outside a cell.
I am looking for something like:
 
D

Don Guillett

sub sumofrange()
mysum=application.sum(range("a3:a15"))
msgbox Merry Xmas
end sub
 
D

Don Guillett

If you want a user defined function, use this one. Type in any cell
=mysum(a1:a33)
However, why not just use =sum(a1:a33) that is built in.

Function mysum(x)
mysum = Application.Sum(x)
End Function

Sub sumofrange()
mysum = Application.Sum(Range("a3:a15"))
MsgBox "Merry Xmas"
End Sub

--
Don Guillett
SalesAid Software
(e-mail address removed)
Don Guillett said:
sub sumofrange()
mysum=application.sum(range("a3:a15"))
msgbox Merry Xmas
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top