logical for next

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

logical for next

Post by sal21 »

i have this for next:

for k=0 to 2

...

next k

and i need to increase from 3000 this block:

0 - 3000
3001 - 6000
6001 - 9000

how to increase the block in the loop of for next?

eaxmple:
for k=0 frist block 0 - 3000
for k=1 frist block 3001 - 6000
for k=2 frist block 6001 - 9000
Last edited by sal21 on 02 Aug 2013, 10:58, edited 1 time in total.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: logical for next

Post by Rudi »

Your question does not make sense as it does not conform to the loop structure.
What do you mean by increase the block?
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78527
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: logical for next

Post by HansV »

As Rudi says, you'll have to provide more information. What do you want to do with the 'blocks'?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: logical for next

Post by sal21 »

HansV wrote:As Rudi says, you'll have to provide more information. What do you want to do with the 'blocks'?
from 0 - to 3000
from 3001 - to 6000
from 6001 - to 9000

User avatar
HansV
Administrator
Posts: 78527
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: logical for next

Post by HansV »

But what do you want to do? :scratch:
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: logical for next

Post by sal21 »

HansV wrote:But what do you want to do? :scratch:
in effect i need a for next cylcle with a steep of 3000 + 3000...

0 3000
3001 6000
6001 9000

User avatar
HansV
Administrator
Posts: 78527
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: logical for next

Post by HansV »

Do you want something like this?

Code: Select all

    Dim k As Long
    Dim j As Long
    For k = 0 To 2
        For j = 3000 * k + 1 to 3000 * k + 3000
            ' your code here
            ...
        Next j
    Next k
Note that the first "block" will be from 1 to 3000, not from 0 to 3000.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: logical for next

Post by sal21 »

HansV wrote:Do you want something like this?

Code: Select all

    Dim k As Long
    Dim j As Long
    For k = 0 To 2
        For j = 3000 * k + 1 to 3000 * k + 3000
            ' your code here
            ...
        Next j
    Next k
Note that the first "block" will be from 1 to 3000, not from 0 to 3000.
:clapping: :clapping: :clapping: :clapping:

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: logical for next

Post by Rudi »

HansV wrote:Do you want something like this?

Code: Select all

    Dim k As Long
    Dim j As Long
    For k = 0 To 2
        For j = 3000 * k + 1 to 3000 * k + 3000
            ' your code here
            ...
        Next j
    Next k
Note that the first "block" will be from 1 to 3000, not from 0 to 3000.
Very nice... :thumbup:
Multiplying with the outer loop is a great move.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.