+ Reply to Thread
Results 1 to 2 of 2

For loop not being launched

Hybrid View

Leia For loop not being launched 05-09-2011, 06:07 AM
Colin Legg Re: For loop not being... 05-09-2011, 06:21 AM
  1. #1
    Registered User
    Join Date
    04-20-2011
    Location
    Swe
    MS-Off Ver
    Excel 2003
    Posts
    9

    For loop not being launched

    Hello!

    The for loop within this do loop is being skipped and therefore I get "divide by 0" error. Why isn't the for loop launched and how can I fix it? msgbox never appears.

        x = 1
        Do
        addi = 0
        addiTotal = 0
           For y = 1 To y = 5
                MsgBox "X: " & x & " Y: " & y
                If jumps(x + y).Value > 0 Then
                    addi = addi + jumps(x + y)
                    addiTotal = addiTotal + 1
                End If
            Next y       
            jumps(x) = (jumps(x) + addi) / addiTotal
            x = x + 5
        Loop Until x >= lopdiff
    Thank you!

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: For loop not being launched

    Hi,

    Change this:
    For y = 1 To y = 5
    To this:
    For y = 1 To 5
    Hope that helps,

    Colin

    RAD Excel Blog

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1