Try something like
Dim Arr() As Variant ' or As Long or As Double
Dim RNdx As Long
Dim CNdx As Long
ReDim Arr(1 To 3, 1 To 6)
' load the array
For RNdx = LBound(Arr, 1) To UBound(Arr, 1)
For CNdx = LBound(Arr, 2) To UBound(Arr, 2)
Arr(RNdx, CNdx) = CNdx * RNdx ' some value
Next CNdx
Next RNdx
' read the array
For RNdx = LBound(Arr, 1) To UBound(Arr, 1)
For CNdx = LBound(Arr, 2) To UBound(Arr, 2)
Debug.Print Arr(RNdx, CNdx)
Next CNdx
Next RNdx
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
"Tom Emmery" <(E-Mail Removed)> wrote in message
news:318CF546-F64C-4D1F-878E-(E-Mail Removed)...
> How to create a 2-dimensional array, initialize it and read from it ?
>
> Example:
> fixed number of rows(3), variable number of values per row (max 6)
>
> I've tried the following code:
> dim MyArray as variant
> redim MyArray(1 to 3, 1 to 7)
>
> How to assign values to it ?
> row 1: (1,"h", 2)
> row 2: (4,"i",5,"j",6,"k",1)
> row 3: (7,"z",3,"y",3)
>
> Then how to select "j" (row 2, index 4) ?
>
>