Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 905
Default How to assign range to Double array?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Range passed to fuction to an array Michael[_4_] Excel Programming 4 March 3rd 09 07:52 PM
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
Assign a 2D array of constant values to a range dodgo Excel Programming 4 October 19th 06 04:46 AM
Excel 2003. Assign array to range Jorge Vinuales Excel Programming 2 May 2nd 06 06:06 PM
Property Let: assign return value of Double when passing String Tetsuya Oguma Excel Discussion (Misc queries) 1 March 3rd 06 08:01 AM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"