PDA

View Full Version : Solved: Filling a simple array



Digita
08-29-2007, 12:04 AM
Howdy,

Just wondering if there is any difference between 2 techniques in filling an array with 10 different elements:


TheArray = Array("Zoo", "Farm", "Paddock", "Sheep", "Cow", "Bird", ?Mice", "Chicken", "Fence", "Post")

TheArray = Range("A1:A10").Value
Same 10 elements are stored in range A1:A10

Thanks & regards

KP

mdmackillop
08-29-2007, 12:34 AM
Flexibility and ease of use.

Consider using a dynamic range name for your Array range
eg Add the range "Data" using Insert/Names/Define and the formula =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)
TheArray = Range("Data").Value This will adjust itself to the length of the data records (no blanks)

Bob Phillips
08-29-2007, 12:44 AM
The first is a one dimensional array, the second is two dimensional.

RichardSchollar
08-29-2007, 02:17 AM
The lower bound (of the first dimension) of the first array will depend on your option base setting (default 0) whereas the second will always be 1.

Richard

Digita
08-29-2007, 06:02 PM
Thanks guys for your prompt input. I'll read up more on 1 & 2 dimensional arrays on how to use them.

Have a nice day.

Regards


KP