Pauses execution to let the system process other events.

* The DoEvents function always returns zero.
* 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.
* DoEvents is most useful for simple things like allowing a user to cancel a process after it has started, for example a search for a file.
* For long-running processes, yielding the processor is better accomplished by using a Timer or delegating the task to an ActiveX EXE component.
* In the latter case, the task can continue completely independent of your application, and the operating system takes case of multitasking and time slicing.
* Any time you temporarily yield the processor within an event procedure, make sure the procedure is not executed again from a different part of your code before the first call returns; this could cause unpredictable results.
* In addition, do not use DoEvents if other applications could possibly interact with your procedure in unforeseen ways during the time you have yielded control.
* For more information about timing a macro, refer to the Macros > Timing page.
* For the Microsoft documentation refer to

Dim PauseTime As Integer 
Dim Start As Single
Dim Finish As Single
Dim TotalTime As Single

PauseTime = 3
Start = VBA.Timer()
Do While VBA.Timer() < (Start + PauseTime)
Finish = VBA.Timer
TotalTime = Finish - Start

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top