# For Next loop with uneven intervals

• Hello,

I was wondering if it's possible to create a For Next loop with uneven intervals as described below as opposed to creating many different loops.

ie.

For i = (1 To 50), (100-150), (200-250)
..........
Next

• Hard to tell exactly what you are trying to do, but could you use
For i = a to b and set the values of a to b accordingly?

• If you mean 1 - 50, 101-150, 201 - 250 you could do:

Code
``````For J = 0 to 2
For I = (1 + 100 * J) to (50 + 100 * J)

'Code here

Next
Next``````

TJ

• Thank you for your response. I'll try to explain a little more clearly.

I have an array of 3650 values corresponding to 10 years of daily information. I want to place values from 12 worksheet cells into the array. For example lets say I have a counter i for the array. I want the first value from the worksheet cell to be placed in the array i values of 1-30, 365-395, 730-760, 1095-1125 and so on. I was wondering if I could use a one loop to place the values into the array as opposed to a loop for each interval.

I hope this description makes it easier to understand.
Thanks again,

dannyo

• thank you tinyjack,

Cheers,

dannyo

• I would opt to use 3 seperate loops for greater speed. I.e

• Something like this

Code
``````For i = 0 To 2
j = Array(0, 365, 1095)(i)
For x = j To j + 30
'code
Next x
Next i
End Sub``````

If you walked away smiling-then for you the price was right

• I suspect this is very similar to other answers that will be posted in the meantime, but here goes:

Hope this helps.

Regards,
Batman.

[COLOR="Purple"]Regards,[/COLOR]
[COLOR="Purple"]Batman.[/COLOR]

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!