Answered by:
Using math functions in Visual Basic
Question

I'm using VB to write a macro in Excel. Now, VB has plenty of defined functions such as cos(), log(), etc., but I'd like to be able to use an _extremely_simple_ expression like
X = sum(A, B, C)
but I get the error that this function is not defined. There HAS to be some way of summing besides using the "+" operator...
If I use
X = math.sum(A, B, C), I also get an error.
It would be easy to do this with spreadsheet values, but I'd like to have the calculations take place within the macro.
If anyone knows how to do this, I would very much appreciate learning how!
Thanks.
Answers
All replies


Thanks John. I appreciate you pointing out the distinction. I'm sure it's apparent from my question that I'm pretty naive in this area!
The Excel function example I was looking at used spreadsheet cells to contain the range, and I wanted to work with arrays soley in VB. But now that I look closer, it appears I should be able to use Excel functions of the form Application.WorksheetFunction.<function name>()
to do what I'm attempting.
Thanks again for responding.
Regards,
Frank (a.k.a. Camcik)