Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Simple question on For...Next loop
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
simple loop needed please | Excel Discussion (Misc queries) | |||
I need a simple loop with a 4+ row added in. | Excel Discussion (Misc queries) | |||
Some help w/ simple loop, please? | Excel Programming | |||
simple loop macro | Excel Programming | |||
simple loop macro | Excel Programming |