Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
extracting a subset of an array with VBA.
Hi all,
I need to extract an array from another. The dest array will contain,e.g., the even elements of the first one. Which code of VBA could help me? I've thought something this Function Subset (source As range) As ? (I don't know, I need an array, not a range) .... my algorithm ... End Function This function will be called in a cell as an argument inside several Excel functions. Could someone tell me how can I return an array? Do I have to take care about some troubles in particular in building this function? Thanks in advance, Alex. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
extracting a subset of an array with VBA.
Use a variant to return arrays
----- y wrote: ---- Hi all I need to extract an array from another. The dest array will contain,e.g., the even elements of the first one Which code of VBA could help me I've thought something thi Function Subset (source As range) As ? (I don't know, I need an array, not a range .... my algorithm .. End Functio This function will be called in a cell as an argument inside several Excel functions Could someone tell me how can I return an array? Do I have to take care about some troubles i particular in building this function Thanks in advance Alex |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
extracting a subset of an array with VBA.
chris wrote:
Use a variant to return arrays. ----- y wrote: ----- Ok, thanks! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
extracting a subset of an array with VBA.
You might want to consider the SubArray function in the freely
downloadable file at http://home.pacbell.net/beban. Alan Beban y wrote: Hi all, I need to extract an array from another. The dest array will contain,e.g., the even elements of the first one. Which code of VBA could help me? I've thought something this Function Subset (source As range) As ? (I don't know, I need an array, not a range) ... my algorithm ... End Function This function will be called in a cell as an argument inside several Excel functions. Could someone tell me how can I return an array? Do I have to take care about some troubles in particular in building this function? Thanks in advance, Alex. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
extracting a subset of an array with VBA.
"Alan Beban" wrote...
You might want to consider the SubArray function in the freely downloadable file at http://home.pacbell.net/beban. .... y wrote: I need to extract an array from another. The dest array will contain,e.g., the even elements of the first one. There are two ways to read the OP's request: the resulting array contains the even index entries or the even valued entries of the original range/array. Having reread the code for SubArray, it's not immediately obvious to me how it could accomplish either of these tasks. Perhaps you could respond and enlighten with some actual code showing how SubArray could be used to do either of these tasks. To the OP: if you want a VBA function to return an array, the function's return type must be Variant and you'd assign an array to its result. As a simplistic example, Function foo(n As Long) As Variant Dim i As Long, rv As Variant ReDim rv(1 To n) For i = 1 To n rv(i) = i Next i foo = rv End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Extracting a list from an array | Excel Worksheet Functions | |||
Sum of subset of an array | Excel Worksheet Functions | |||
Populate an array that is a subset of a larger array? | Excel Worksheet Functions | |||
How to enter symbols for subset or element of a subset in Excel? | Excel Worksheet Functions | |||
extracting a subset of an array with VBA. | Excel Programming |