hymie
0
Q:

office wait milliseconds

'VBA function to delay execution:

Function Delay(ms)
    Delay = Timer + ms / 1000
    While Timer < Delay: DoEvents: Wend
End Function

'To delay program execution for 250 milliseconds:
Delay 250

'-------------------------------------------------------------------

'Excel VBA includes the Wait method on the Application object:
Application.Wait Now + TimeValue("00:00:25")
'The above will delay VBA execution for 25 seconds. But 
'Application.Wait is unreliable for delays less than a second.

'There is also the Sleep Win32 API, but the Delay() function above 
'works better. 

'Both Application.Wait and Sleep() block the entire Excel interface. 
'Excel literally goes to sleep until the wait period is over. Delay() 
'does not block the Excel interface; it just prevents VBA from 
'continuing until the delay is over.
2

New to Communities?

Join the community