Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default How to create a UDF to return an array of values with input variab

Hi,

I need to create a UDF to return an array of values with some specified
input variables/values, like inputing the interest rates and a set of periods
of time to get an array of annuity factors.

How can I do this?

I really appreciate any help in this issue.

Thanks a lot in advance,
Laurie


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to create a UDF to return an array of values with input variab

Function laurie() As Variant
v = Array(1, 2, 3)
laurie = v
End Function


In the worksheet, select cells A1, B1, C1
type:
=laurie() and complete with CNTRL-SHIFT-ENTER
--
Gary''s Student - gsnu200745


"Laurie" wrote:

Hi,

I need to create a UDF to return an array of values with some specified
input variables/values, like inputing the interest rates and a set of periods
of time to get an array of annuity factors.

How can I do this?

I really appreciate any help in this issue.

Thanks a lot in advance,
Laurie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default How to create a UDF to return an array of values with input variab

On Wed, 19 Sep 2007 13:26:02 -0700, Laurie
wrote:

Hi,

I need to create a UDF to return an array of values with some specified
input variables/values, like inputing the interest rates and a set of periods
of time to get an array of annuity factors.

How can I do this?


Here's an example of a UDF that returns an array

Public Function Factors(rRates As Range, rDays As Range)

Dim aReturn() As Double
Dim rCell As Range
Dim i As Long

ReDim aReturn(1 To rRates.Cells.Count)
i = 0

For Each rCell In rRates.Cells
i = i + 1
aReturn(i) = rCell.Value / 365 * rDays(i).Value
Next rCell

Factors = aReturn

End Function

The variable aReturn holds all the return values and the function name is
set equal to this array variable at the end of the function.

Note that it assumed that rRates and rDays are ranges with the same number
of cells that correlate in some way, but there is no error-checking to make
sure that's the case.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to create a UDF to return an array of values with input variab

Laurie,

See the sections entitled "Returning Arrays From Functions" and "Returning
Arrays With Two Dimensions" on the page
http://www.cpearson.com/Excel/Writin...ionsInVBA.aspx

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Laurie" wrote in message
...
Hi,

I need to create a UDF to return an array of values with some specified
input variables/values, like inputing the interest rates and a set of
periods
of time to get an array of annuity factors.

How can I do this?

I really appreciate any help in this issue.

Thanks a lot in advance,
Laurie



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default How to create a UDF to return an array of values with input va

Thanks for the big help, Chip, Dick and Gary''s Student!!

Now I know how to create a UDF returning arrays (one or two dimensional),
which is great and is what I was exactly looking for.

The next question is that how I can refer to the resulted arrays in another
UDF to do other calculations? Like referring to a specific element in the
array one at a time in another UDF.


Thank you all again!!!!!!

Sincerely,
Laurie



"Chip Pearson" wrote:

Laurie,

See the sections entitled "Returning Arrays From Functions" and "Returning
Arrays With Two Dimensions" on the page
http://www.cpearson.com/Excel/Writin...ionsInVBA.aspx

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Laurie" wrote in message
...
Hi,

I need to create a UDF to return an array of values with some specified
input variables/values, like inputing the interest rates and a set of
periods
of time to get an array of annuity factors.

How can I do this?

I really appreciate any help in this issue.

Thanks a lot in advance,
Laurie



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
Create a List Output from a Horizontal Array Input Rob Excel Worksheet Functions 4 September 17th 09 05:40 PM
How to return an array of values that are not zero/Null apache007 Excel Discussion (Misc queries) 9 May 15th 09 06:00 AM
Use array to return array of values Brad Excel Worksheet Functions 2 March 30th 06 05:58 PM
Return an array of values from a function Raul Excel Programming 6 December 13th 04 07:33 PM
VBA Syntax for VLOOKUP to return array of return values Alan Beban[_3_] Excel Programming 7 August 5th 03 11:41 AM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"