View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
sali[_2_] sali[_2_] is offline
external usenet poster
 
Posts: 24
Default How To Fill 2D Arrays Easily

wrote in message
oups.com...
I'm sorry I've told you the wrong thing! (Early morning blues)
I've hust tried to see how your posts would help me.......and noticed
I've posted totally the wrong scenario.
My apologies.

Dim testarray()
ReDim testarray(1 To 5, 1 To 256)

testarray() = Range("B9:L9").Value
testarray() = Range("B14:L14").Value

End Sub

This is what my first post should have been where the 2nd line
ovrwrites the array data.
I want to copy 5 ranges into my Array. The length of each range is
identical but not known before hand hence 1 to 256.


try this:
dim testaray(5) as variant
testaray(1)=range("a1:a100").value
testaray(2)=range("b1:b250").value

run code with debug ["step_into"] and watch the "locals" window.

idea is to have "array of arrays", so each row may have different size.
since this is "array of arrays", to access data you need [for example]:
testaray(1)(99)
you are not limited to fixed rows*cols matrix!