R
RK
I'm trying to do a User Defined Function (UDF) that calculates the payback
period for an investment. But before that, I can't even get right a simple
UDF that returns the sum of a selected range (similar to Excel's SUM
function). What's wrong with the following code?
Function Grandtotal(ParamArray inputrange() As Variant) As Double
Dim cell As Variant, Total As Double
Total = 0
For Each cell In inputrange
Total = Total + cell.Value
Next
Grandtotal = Total
End Function
I keep getting a #VALUE! result.
Thanks.
period for an investment. But before that, I can't even get right a simple
UDF that returns the sum of a selected range (similar to Excel's SUM
function). What's wrong with the following code?
Function Grandtotal(ParamArray inputrange() As Variant) As Double
Dim cell As Variant, Total As Double
Total = 0
For Each cell In inputrange
Total = Total + cell.Value
Next
Grandtotal = Total
End Function
I keep getting a #VALUE! result.
Thanks.