View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default How to copy VBA array into range of cells?

wrote:
. . .
I am surprised that if xdata(10) specifies a row spanning 10 columns,
xdata(10,0), not xdata(0,10), specifies a column spanning 10 rows. Oh
well. . . .

Static arrays can be declared by specifying the lower bound and upper
bound of each dimension, or by specifying only the upper bound and
leaving the lower bound to be determined by the Option Base statement or
its default (which is 0).

So, for 1-dimensional arrays, the bounds of the array refers to the
number of the columns, since by definition there is only one row. Dim
xdata(10) is the equivalent of Dim xdata(1 to 10) or Dim xdata(0 to 10).
In all those cases, the 10 refers to the upper bound in the columns
"direction".

Correlatively, for 2-dimensional arrays, Dim xdata(10,0) is declaring
only the upper bound of each dimension, leaving to the Option Base
statement or its default, the determination of the lower bounds, and is
equivalent to Dim xdata(0 to 10, 0 to 0). Similarly, Dim xdata(0,10) is
the equivalent of Dim xdata(0 to 0, 0 to 10). By the way, since 0 is
specified as an upper bound, both declarations will fail if the Option
Base 1 statement is in effect.

Regards,
Alan Beban