Re: can .range return a 1D array?
- From: Alan Beban <unavailable@xxxxxx>
- Date: Wed, 14 May 2008 11:04:34 -0700
Bruce Bowler wrote:
Consider the example of implementing an algorithm that "works best" with a 1D array. Consider the case where sometimes you want to call that code with row (or portion of a row) worth of data and the SAME code with a column (or portion there of) worth of data. In 1 case the subscripts are (I,1), in the other they're (1,I). Yes, I know I could implement it with 2 loops going from lbound(x,1) to ubound(x,1) and lbound(x,2) and ubound
(x,2). Now suppose I (or someone else who borrowed the code) wants to call it with an array created via the ARRAY function. Yep, could code that too, but the code is *MUCH* simpler to understand (and less likely to contain errors) if it treats the input as a vector rather than an array.
I know moan and groan, it's not going to change. I'll just live with it.
Perhaps the following might be useful.
If arr is a single column 2-D array, then
arr = Application.Transpose(arr) will convert it to a 1-D array.
And if arr is a single row 2-D array, then
arr = Application.Index(arr,1,0) will convert it to a 1-D array.
And if the functions in the freely downloadable file at http://home.pacbell.net/beban are available to your workbook, then
arr = OneD(arr) will convert either a single row 2-D array or a single column 2-D array to a 1-D array, and will leave a 1-D array as a 1-D array.
Alan Beban
.
- Follow-Ups:
- Re: can .range return a 1D array?
- From: Dave Peterson
- Re: can .range return a 1D array?
- From: Jon Peltier
- Re: can .range return a 1D array?
- References:
- can .range return a 1D array?
- From: Bruce Bowler
- Re: can .range return a 1D array?
- From: Charles Williams
- Re: can .range return a 1D array?
- From: T Lavedas
- Re: can .range return a 1D array?
- From: Bruce Bowler
- can .range return a 1D array?
- Prev by Date: Re: web query tables destination
- Next by Date: test
- Previous by thread: Re: can .range return a 1D array?
- Next by thread: Re: can .range return a 1D array?
- Index(es):
Relevant Pages
|
Loading