Consulting

Results 1 to 4 of 4

Thread: Solved: My "do while" loop doesn't complete

  1. #1

    Solved: My "do while" loop doesn't complete

    Right as my code gets to the line with the stars, it goes back to the top "Sub Calculate()" line. Anyone know whats up?

    [vba]Sub Calculate()

    Dim x
    x = 0


    Do While x < 30

    Range(Cells(6, 3 + x), Cells(11, 3 + x)).Copy

    Sheets("Monte Carlo Sim").Select
    Range("B5").PasteSpecial Paste:=xlPasteValues

    Calculate****
    Range("DA40005").Copy
    Range("I40010").PasteSpecial Paste:=xlPasteValues

    Calculate
    Range("DA40005").Copy
    Range("I40011").PasteSpecial Paste:=xlPasteValues

    Range("B5").Value = Range("B5").Value + 1

    Calculate
    Range("DA40005").Copy
    Range("J40010").PasteSpecial Paste:=xlPasteValues

    Calculate
    Range("DA40005").Copy
    Range("J40011").PasteSpecial Paste:=xlPasteValues


    Range("K40013").Copy
    Worksheets("Main").Cells(19, 3 + x).PasteSpecial Paste:=xlPasteValues

    x = x + 2

    Loop


    End Sub[/vba]

  2. #2
    VBAX Regular
    Joined
    Feb 2009
    Posts
    16
    Location
    Your sub name is "Calculate" and "the line with the stars" invokes "Calculate" so the subroutine is being called recursively.

  3. #3
    I'm stupid.

  4. #4
    edit ill make a new post for my new problem. thanks for the quick solution sagy
    Last edited by Tuneman12; 03-24-2009 at 09:28 AM.

Posting Permissions

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