Consulting

Results 1 to 6 of 6

Thread: next iteration in loop

  1. #1

    next iteration in loop

    Hello everyone,

    Is there a way to go to the next iteration within a loop when it reaches a certain value?

    Thanks

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    When what reaches a certain value?
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
     
     a = 0
        Do While a < nr_comp + 1
            base = vtresult(0, a, 0, 1) * 1.005
            i = 0
            Do While vtresult(i, a, 0, 1) <= base
                t = vtresult(i, a, 0, 1)
                If (i <= 15) Then
                    iGo = i - 1
                    Else
                    iGo = 3333
                
                End If
                    i = i + 1
        Loop
    When i gets above 15 it needs to go to the next.

  4. #4
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    Your code is not complete amateur1902 and your phrase is not complete
    'When i gets above 15 it needs to go to the next what?'
    Maybe you're referring to the code needing to jump to the outer Do...Loop but still, you leave us only guessing...
    Try this but it is pure speculation of what you might mean to say...
    [vba]a = 0
    Do While a < nr_comp + 1
    base = vtresult(0, a, 0, 1) * 1.005
    i = 0
    Do While vtresult(i, a, 0, 1) <= base
    t = vtresult(i, a, 0, 1)
    If (i <= 15) Then
    iGo = i - 1
    Else
    iGo = 3333
    Exit Do '<-- If by 'needs to go to the next' you mean 'go to the outer Do...Loop'
    End If
    i = i + 1
    Loop
    a = a + 1 '???? Something must be happening to variable a here I guess
    Loop
    [/vba]
    Last edited by tstav; 04-08-2008 at 11:45 AM.
    He didn't know it was impossible, so he did it. (Jean Cocteau)

  5. #5
    Hi Tstav,

    Thanks for youre reply. Youre answer was 'speculative', but it made the code perfect . It now stops when i want to.

    Thanks ,

    Amateur

  6. #6
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    Have a nice day ,
    tstav
    He didn't know it was impossible, so he did it. (Jean Cocteau)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •