Hi guys. I'm new here and i'd like to see if anyone know how to make this work.
In a Module i made this function:
Function PProduct(arr() As Variant) As Double
Dim soma As Double
Dim i As Long
soma = 1
For i = LBound(arr, 1) To UBound(arr, 1)
soma = soma * arr(i, 1)
Next i
PProduct = soma
End Function
And when i call this function from a cell like:
=PProduct(A1:C3)
I got the #VALUE! problem.
The range A1:C3 is number only, populated with 1 2 3; 4 5 6; 7 8 9
In an attempt to solve the problem i wrote this sub
Sub test()
Dim arr() As Variant
arr = Sheet1.Range("A1:C3")
Debug.Print PProduct(arr)
End Sub
wich returns 28
What do I have to do to make this UDF work in a worksheet cell call?
In a Module i made this function:
Function PProduct(arr() As Variant) As Double
Dim soma As Double
Dim i As Long
soma = 1
For i = LBound(arr, 1) To UBound(arr, 1)
soma = soma * arr(i, 1)
Next i
PProduct = soma
End Function
And when i call this function from a cell like:
=PProduct(A1:C3)
I got the #VALUE! problem.
The range A1:C3 is number only, populated with 1 2 3; 4 5 6; 7 8 9
In an attempt to solve the problem i wrote this sub
Sub test()
Dim arr() As Variant
arr = Sheet1.Range("A1:C3")
Debug.Print PProduct(arr)
End Sub
wich returns 28
What do I have to do to make this UDF work in a worksheet cell call?