J
Joe User
What kind of object is passed to a VB function when called from Excel with
reference union like (A1,A3,A5)?
How can I determine the size of the union (number of references)?
Consider the following paradigm:
Function myIRR(myVal As Range, _
Optional myGuess As Double = 0.1, _
Optional n As Long = 0)
Dim dVal() As Double
If n <= 0 Then n = myVal.Rows.Count
ReDim dVal(1 To n)
n = 0
For Each cell In myVal: n = n + 1: dVal(n) = cell: Next
myIRR = IRR(dVal, myGuess)
End Function
That works with (A1,A3,A5), but I must pass n=3. myVal.Rows.Count is 1
unless myVal is a contiguous range like A1:A5.
PS: I know that I can use WorksheetFunction.IRR instead for this example.
I am using IRR just for demonstration purposes.
reference union like (A1,A3,A5)?
How can I determine the size of the union (number of references)?
Consider the following paradigm:
Function myIRR(myVal As Range, _
Optional myGuess As Double = 0.1, _
Optional n As Long = 0)
Dim dVal() As Double
If n <= 0 Then n = myVal.Rows.Count
ReDim dVal(1 To n)
n = 0
For Each cell In myVal: n = n + 1: dVal(n) = cell: Next
myIRR = IRR(dVal, myGuess)
End Function
That works with (A1,A3,A5), but I must pass n=3. myVal.Rows.Count is 1
unless myVal is a contiguous range like A1:A5.
PS: I know that I can use WorksheetFunction.IRR instead for this example.
I am using IRR just for demonstration purposes.