+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Sudden "freeze" while executing vba-loop

  1. #1
    Registered User
    Join Date
    05-31-2010
    Location
    norway
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Sudden "freeze" while executing vba-loop

    Solve: Adding in DoEvents in the code removed the random halts.

    I have been exploring the more entertaining sides of excel recently, mostly by various animations performed through vb-algorithms. By manipulating the fill-color in cells, I have been able to replicate a simple snake-game, fireworks-animations and now a simple wave-simulation.

    However, upon execution of any of these little programs, it seems as though the code stops executing after about 5-10 seconds or so.
    Task manager says excel is using ~100% cpu for the entire execution of the program. After the program is seemingly halted, the cpu usage is still 100%, and the worksheet is "locked" as though a program was running some code on it. I need to press CTRL+break to stop the code properly, after which I can restart the code without any problems for the next 5-10 seconds.

    Surely I must be missing something.

    Here is the code for the wave-simulator (with no real delay, thus making the animation way too fast on any new computers):
    Please Login or Register  to view this content.
    Last edited by JohnFred; 05-31-2010 at 07:50 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Sudden "freeze" while executing vba-loop

    try adding a DoEvents inside the While/Wend loop.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-31-2010
    Location
    norway
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Sudden "freeze" while executing vba-loop

    Ah! Very good, my code is running smoothly now without any weird halts.

    Thank you!

+ 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