Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Returning an Array from a called function within a macro | New Users to Excel | |||
index match array function-returning only first match, need last. | Excel Worksheet Functions | |||
Returning an array from the INDEX function | Excel Worksheet Functions | |||
returning an array from a custom function | Excel Programming | |||
Returning single/multiple values from array function | Excel Programming |