Share via

Application.Wait

Randy Avery 0 Reputation points
2026-04-30T14:32:24.8266667+00:00

give me an example of Application.Wait in VBA code.

Developer technologies | Visual Basic for Applications
0 comments No comments

2 answers

Sort by: Most helpful
  1. Nancy Vo (WICLOUD CORPORATION) 5,700 Reputation points Microsoft External Staff Moderator
    2026-05-01T03:24:13.3866667+00:00

    Hello @Randy Avery ,

    Thanks for your question.

    You can refer to these following code examples:

    Wait for a fixed number of seconds:

    Sub WaitForSeconds()
        Dim pauseTime As Long
        pauseTime = 3
    
        MsgBox "Macro will pause for " & pauseTime & " seconds. Click OK to start."
    
        Application.Wait Now + TimeValue("00:00:03")
    
        MsgBox "3 seconds have passed. Resuming macro!"
    End Sub
    

    Wait until a specific time:

    Sub WaitUntilSpecificTime()
        MsgBox "Waiting until 14:30:00..."
    
        Application.Wait TimeValue("14:30:00")
    
        MsgBox "It's now 2:30 PM! Resuming macro."
    End Sub
    

    Or wait inside a loop:

    Sub WaitInLoop()
        Dim i As Integer
    
        For i = 1 To 5
            Debug.Print "Step " & i & " at " & Now
            Application.Wait Now + TimeValue("00:00:02")
        Next i
    
        MsgBox "Loop complete!"
    End Sub
    

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    Was this answer helpful?


  2. AI answer

    2026-04-30T14:32:35.2766667+00:00

    Below is a simple VBA example that pauses a macro for 10 seconds using Application.Wait:

    Sub PauseForTenSeconds()
        Dim waitTime As Date
    
        'Calculate a time 10 seconds from now
        waitTime = Now + TimeValue("0:00:10")
    
        'Pause code execution until that time
        Application.Wait waitTime
    
        MsgBox "10 seconds have passed."
    End Sub
    

    Another example pauses the macro until a specific time of day (6:23 PM today):

    Sub WaitUntilSpecificTime()
        Application.Wait "18:23:00"
    End Sub
    

    Application.Wait suspends Excel activity until the specified time is reached, but background processes such as printing and recalculation continue.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.