View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Beto[_3_] Beto[_3_] is offline
external usenet poster
 
Posts: 140
Default Populate a matrix, How?

Hi,
I'm trying to populate a matrix but I can't figure it out a better way.

Example matrix:

[ 10 100 ]
[ 20 200 ]
[ 30 300 ]

I want a similar way to this: (that does not work)

Dim myMatrix As Variant
ReDim myMatrix(1 To 3, 1 To 2)
myMatrix = Array(Array(10, 20, 30), Array(100,200,300))

This redimensions the matrix to a 6 element array, so is not working as
I want it.
I know I can use "myMatrix(1,1) = 10" and so on, but I think there must
be a better way.
I also know that I can use a hidden sheet and then just copy the data
from the sheet to the matrix, but i'd like a only VBA code solution.

Can something like this be done?
Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.