Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I assign the value of a range to a Double array?
The best I can do is a For Each loop. For example: Function myIRR(myVal As Range, _ Optional myGuess As Double = 0.1) Dim dVal() As Double, n as Long ReDim dVal(1 To myVal.Rows.Count) n = 0 For Each cell In myVal: n = n + 1: dVal(n) = cell: Next myIRR = IRR(dVal, myGuess) End Function If dVal() were Variant, I could copy the range simply as follows: Function myIRR(myVal As Range, _ Optional myGuess As Double = 0.1) Dim dVal() dVal = myVal myIRR = IRR(dVal, myGuess) End Function But that results in a Type Mismatch error because the VB IRR function wants a Double array. PS: I know that I can use WorksheetFunction.IRR instead for this example. I am using IRR just for demonstration purposes. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assign Range passed to fuction to an array | Excel Programming | |||
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) | Excel Programming | |||
Assign a 2D array of constant values to a range | Excel Programming | |||
Excel 2003. Assign array to range | Excel Programming | |||
Property Let: assign return value of Double when passing String | Excel Discussion (Misc queries) |