Could you please explain to me why the following code works?
Sub MyTest()
Dim arrL1(3) As Variant
Dim arrTemp(10) As Variant
Dim i As Long, j As Long, s As String
Dim varTemp As Variant
For i = LBound(arrL1) To UBound(arrL1)
For j = LBound(arrTemp) To UBound(arrTemp)
arrTemp(j) = i + j
Next
**arrL1(i) = arrTemp**
Next
' 2nd part of the code
**For i = LBound(arrL1) To UBound(arrL1)**
varTemp = arrL1(i)
s = ""
For j = LBound(varTemp) To UBound(varTemp)
s = s & Format(varTemp(j), "@@@")
Next
Debug.Print s
Next
End Sub
What is confusing me is the first "starred" line arrL1(i) = arrTemp. When I try to assign an array in this way in my project I get an Object or Application defined error.
Another confusing line is in the 2nd part, i.e., varTemp = arrL1(i). Do we really need another variable varTemp? Can we not get away with just arrL1(i)?
Thank you in advance.