Quote:
> Does "for each" loop work with multi-dimensional arrays?
Yes it does, but i don't know if it can iterate over 1 particular dimension.
A for each over a multi dimensional array prints all the array elements
seprately (0,1) then (1,1) then (1 ,0) etc.
Here is a small example:
Private Sub Command1_Click()
Dim MyArray As Variant
Dim i As Integer
Dim ArrayEntry As Variant 'For each - loop variable must be of type variant
ReDim MyArray(1, 0) 'Declare as 2 dimensional array
For i = 0 To 9
ReDim Preserve MyArray(1, i)
MyArray(0, i) = "Label" & Str(i)
MyArray(1, i) = "Value" & Str(i)
Next i
For Each ArrayEntry In MyArray
Debug.Print ArrayEntry 'Prints all the values of the array
consequetively
Next ArrayEntry
End Sub
Greetings,
Maarten.