Sunday, November 25, 2012

Vba sleep

vba sleep in Microsoft Excel


Add a delay, a timer or a sleep function in your vba Excel 2010 and 2013 documents. Pause your macro until a specific time or a specific delay.

add delay in Excel

Here is the code sample:



'====================
' for a specific time
' will display Hello at 11:28 AM
'====================
Public Sub Test1()
    Application.Wait("11:28:00")
    MsgBox("hello")
End Sub


'====================
'for a specific delay
' will display Hello at in 3 seconds from now
'====================
Public Sub Test2()
    Application.Wait(Now + TimeValue("0:00:03"))
    MsgBox("hello")
End Sub




You don’t need to add COM or 32 bits DLL library. Excel integer his how wait function since 2010.

If you like this post, leave a comment or share it.

 Download the sample : vba sleep.xlsm

Reference :

MSDN Application.Wait Method (Excel) : http://msdn.microsoft.com/en-us/library/office/ff822851.aspx

No comments:

Post a Comment