ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning arrays (https://www.excelbanter.com/excel-programming/393165-returning-arrays.html)

Steve

Returning arrays
 
I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.

Bob Phillips

Returning arrays
 
INDEX into it like this

=INDEX(myfunc(A1:A5),3)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Steve" wrote in message
...
I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.




Charlie

Returning arrays
 
in VB the syntax would be:

OneElement = MyFunc(Whatever)(1)
NextElement = MyFunc(Whatever)(2)
etc.

unfortunately including the trailing element number doesn't work when the
function is used as a cell formula

=MyFunc(Whatever)(1)

What I would do is add an optional Arg to return just the one element desired:

=MyFunc(Whatever,1)



"Steve" wrote:

I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.


Alan Beban

Returning arrays
 
=INDEX(MyFunction(),3,4) for the array element in the 3d "row", 4th
"column" of the array returned by the function "MyFunction".

Alan Beban

Steve wrote:
I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.


Charlie

Returning arrays
 
I learned something new from you and Bob

"Alan Beban" wrote:

=INDEX(MyFunction(),3,4) for the array element in the 3d "row", 4th
"column" of the array returned by the function "MyFunction".

Alan Beban

Steve wrote:
I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.



Steve

Returning arrays
 
I learned something from you all. Thank you muchly.

steve


"Charlie" wrote:

I learned something new from you and Bob

"Alan Beban" wrote:

=INDEX(MyFunction(),3,4) for the array element in the 3d "row", 4th
"column" of the array returned by the function "MyFunction".

Alan Beban

Steve wrote:
I have written a user defined function that returns an array.

I want to insert this function into a cell on my worksheet and have a
specific member of the array appear in the cell.

What is the syntax for the formula in the cell on the worksheet that will
access a specific element in the array returned from my function?

Thanks in advance for your help.




All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com