Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default function returning array

I've read that it possible for a function to return an array but I ca
get it working.
I've a function that extracts a string and puts characters in an array
It does so with every string so the size of the array is differen
every time. The idea is that the function returns an array to the sub
For example, the sub is running an index from 1 to 100 and the functio
returns an array with values 11, 14 and 25. If the index is same numbe
as one of the values form the array returned by the function the su
will do some actions..

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default function returning array

On Tue, 8 Jun 2004 02:40:33 -0500, dreamer
wrote:

I've read that it possible for a function to return an array but I can
get it working.
I've a function that extracts a string and puts characters in an array.
It does so with every string so the size of the array is different
every time. The idea is that the function returns an array to the sub.
For example, the sub is running an index from 1 to 100 and the function
returns an array with values 11, 14 and 25. If the index is same number
as one of the values form the array returned by the function the sub
will do some actions...


---
Message posted from http://www.ExcelForum.com/


It should work if you set the function equal to the array:

Function foo(str As String)
Dim i As Long
Dim foobar()

For i = 0 To Len(str)
ReDim Preserve foobar(i)
foobar(i) = Mid(str, i + 1, 1)
Next i
foo = foobar
End Function

foo will contain the array.

Instead of checking the index, you could also consider using Ubound(foo).


--ron
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
Returning an Array from a called function within a macro [email protected] New Users to Excel 1 May 18th 07 03:47 PM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
Returning an array from the INDEX function Agenor Excel Worksheet Functions 2 November 28th 06 12:44 AM
returning an array from a custom function Ron Davis Excel Programming 2 September 15th 03 11:02 AM
Returning single/multiple values from array function Ryan Poth[_2_] Excel Programming 4 July 16th 03 08:06 AM


All times are GMT +1. The time now is 05:28 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"