Name
Application.Wait(Time
)
Synopsis
Pauses Excel.
Argument |
Setting |
---|---|
|
The time to resume Excel |
You can specify an interval of time to wait by incrementing Now
. The following code uses that technique to create a procedure that pauses for an interval specified in milliseconds (the same as the Windows API Sleep
function):
Sub TestSleep( ) ' Wait 5 seconds. Sleep 5000 MsgBox "Time's up!" End Sub Sub Sleep(milsecs As Long) Dim dt As Date ' 0.00001 = 1 second in the Date type. dt = Now + (milsecs / 100000000) Application.Wait (dt) End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.