Simple question on For...Next loop
Hi Alex,
Sub Test2()
Dim arr As Variant
Dim i As Long
arr = Array(1, 2, 5, 7, 12, 15, 20)
For i = LBound(arr) To UBound(arr)
'do something. e.g.:
MsgBox arr(i)
Next
End Sub
---
Regards,
Norman
"Alex" wrote in message
...
Hello.
This should be easy for the pros of the list
I am used to writing For...Next loops as...
For i = 1 to 10
... and sometimes using the Step 2 to not move up by increments of 1.
How do I use the loop structure for an eclectic bunch of numbers e.g.
1,2, 5,7, 12, 15,20
So for example I tried
For col = 1, 2, 5, 7, 12, 15, 20
...but VBA said 'no'.
I managed to do this by forming an array...but I am sure there is an
easier
route.
Regards
Alex
|