+ Reply to Thread
Results 1 to 3 of 3

Nested While Loops Not Executing

Hybrid View

officialhopsof Nested While Loops Not... 06-15-2011, 04:35 PM
officialhopsof Re: Nested While Loops Not... 06-15-2011, 04:39 PM
barryleajo Re: Nested While Loops Not... 06-15-2011, 04:44 PM
  1. #1
    Registered User
    Join Date
    06-10-2011
    Location
    Huntsville, Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Nested While Loops Not Executing

    I have the following situation:

        j = 1
        i = 1
        Do While j <= 5
            Do While i <= 5            
                MsgBox CStr(i) & ":" & CStr(j)
                i = i + 1
            Loop
            j = j + 1
        Loop


    and it appears to only run through the inner loop once and then exits both loops. Are nested loops not possible in VBA?

    Thank you for your time,
    Brandon
    Last edited by officialhopsof; 06-15-2011 at 04:40 PM.

  2. #2
    Registered User
    Join Date
    06-10-2011
    Location
    Huntsville, Alabama
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Nested While Loops Not Executing

    Oh! I am stupid, i forgot to reset 'i'

    sorry about that. thanks anyway guys!

  3. #3
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Nested While Loops Not Executing

    Put

    i=1
    just after the exit of the inner Do Loop

    EDIT: OOPS: Sorry - just beat me to it

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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