I have this code:
Sub test()
Dim i As Long
Dim t As Long
Dim f As Long
Dim m As Long
Dim l As Long
Dim c As Long
lCombinations = (UBound(Track) + 1) * (UBound(Financials) + 1) * _
(UBound(Management) + 1) * (UBound(Liquidity) + 1) * (UBound(Industry) + 1) * (UBound(Security) + 1)
ReDim arrResult(1 To lCombinations, 1 To 6)
For t = 0 To 5
For f = 0 To 5
For m = 0 To 5
For l = 0 To 5
For c = 0 To 5
For s = 0 To 5
i = i + 1
arrResult(i, 1) = Track(t)
arrResult(i, 2) = Financials(f)
arrResult(i, 3) = Management(m)
arrResult(i, 4) = Liquidity(l)
arrResult(i, 5) = Industry(c)
arrResult(i, 6) = Security(s)
Debug.Print Security(s)
Next s
Next c
Next l
Next m
Next f
Next t
'to test the array
Range(Cells(1), Cells(lCombinations, 6)) = arrResult
End Sub
And it works fine through the first 5 iterations of the i+1 loop, but when it comes to "Next C" I get an error that says subscript out of range. Any ideas why this may be happening?
Any help would be greatly appreciated.
Cheers,
Ali
Bookmarks