Forum Discussion

chahine's avatar
chahine
Iron Contributor
Apr 01, 2022
Solved

doevents & application.wait

hello everyone i want to understand how doevents works, for animating chart why we should use do events? what i understand doevents is used to stop the macro code from executing, but how this relate...
  • HansVogelaar's avatar
    Apr 01, 2022

    chahine 

    From DoEvents function:

    "DoEvents passes control to the operating system. Control is returned after the operating system has finished processing the events in its queue and all keys in the SendKeys queue have been sent."

    As a result, macro execution slows down slightly, but it doesn't stop.

    On the other hand, from Application.Wait method (Excel):

    "The Wait method suspends all Microsoft Excel activity and may prevent you from performing other operations on your computer while Wait is in effect. However, background processes such as printing and recalculation continue."

    So a macro comes to a complete standstill during the time specified by Application.Wait.

Resources