Re: can .range return a 1D array?
- From: Dave Peterson <petersod@xxxxxxxxxxxxxxxx>
- Date: Thu, 15 May 2008 06:35:41 -0500
And if arr is a single row 2-D array, then
As will:
with application
arr = .transpose(.Transpose(arr))
end with
just another way...
Alan Beban wrote:
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
--
Dave Peterson
.
- Follow-Ups:
- Re: can .range return a 1D array?
- From: Alan Beban
- 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
- Re: can .range return a 1D array?
- From: Alan Beban
- can .range return a 1D array?
- Prev by Date: Change the default style to a comment
- Next by Date: Re: PageSetup is very slow
- 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