To make an Excel VBA macro pause for about five seconds, call Application.Wait with a time five seconds in the future. In Excel for Microsoft 365 on Windows, put the following procedure in a standard VBA module, then call it where the pause is needed:
Sub WaitFiveSeconds()
Dim resumeAt As Date
' Set a time five seconds from now, then pause the macro.
resumeAt = Now + TimeSerial(0, 0, 5)
Application.Wait resumeAt
End Sub
The pause is useful when a macro needs to wait before continuing, but it is not a precision timer and can make Excel less responsive while it waits. Save a copy of your workbook before running a macro: VBA changes cannot be reversed with Ctrl+Z.
How Application.Wait works
Application.Wait is an Excel VBA method that suspends the running macro until a specified date and time. In the example, Now supplies the current date and time, while TimeSerial(0, 0, 5) represents five seconds. Adding them creates the time when the macro should resume. The method expects a time value, not a number of seconds, which is why the expression uses a date-and-time calculation.
The procedure pauses only at the point where the method runs. Statements before it have already executed; statements after it wait until Excel reaches the requested time. That makes the method simple to insert into an existing sequence. For example, if a macro writes a status to a cell, waits, and then clears the status, the cell is not cleared until the pause ends.
Think of this as a practical delay rather than a stopwatch guarantee. Excel must reach the requested time and continue running the macro, so operating-system scheduling or other work can affect when the next line actually runs. Use it when an approximate five-second gap is appropriate, not when an application must act at an exact millisecond.
Where to put and run the VBA code
In Excel for Microsoft 365 on Windows, first save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it needs to retain VBA. Press Alt+F11 to open the Visual Basic Editor. In the editor, choose Insert > Module, paste the procedure into the new module, and return to Excel. Press Alt+F8, select WaitFiveSeconds, and choose Run. Excel may ask you to enable macros; only enable them for files and sources you trust.
To use the delay in another macro, place the wait statement between the action that should happen first and the action that should happen afterward. You can either call the helper procedure with WaitFiveSeconds or put the time calculation and Application.Wait line directly in the other procedure. A helper is easier to reuse and gives the pause a clear name.
On a Mac, Excel also supports VBA and Application.Wait, but the Visual Basic Editor and keyboard shortcuts differ by keyboard and Excel version. Open the editor using Excel’s Developer tab or the Visual Basic Editor command available in your installation, then insert a standard module as on Windows. The Windows Alt+F11 shortcut should not be assumed to work on a Mac; use Excel’s displayed command or customize the shortcut if needed. Excel for the web does not run VBA macros, so open the workbook in the desktop app.
Using the pause between macro actions
A delay is most useful when the next instruction should not begin immediately after an earlier action. For example, a macro may update a cell, let a user read a temporary message, and then continue. Keep the delay close to the action it relates to, and comment on why it is present. A comment such as “allow the status message to remain visible” is more helpful to a future maintainer than a bare five-second pause.
For a repeated pause, call the helper wherever the delay is needed rather than copying several versions of the timing expression. For a different interval, change the arguments to TimeSerial: its order is hours, minutes, seconds. For example, TimeSerial(0, 0, 2) represents two seconds, and TimeSerial(0, 1, 0) represents one minute. If the requested delay could cross midnight, using Now plus the interval still describes a future date and time; avoid replacing it with a time-only value that discards the date.
What happens to Excel during the wait
Application.Wait is easy to read, but it pauses Excel activity while waiting. The Excel window may appear unresponsive, and the user may not be able to interact with the workbook normally until the macro resumes. This is an important trade-off: a five-second pause may be harmless in a short, unattended procedure, but it can feel like a freeze if the macro is part of an interactive task.
The method also does not make a slow operation finish sooner. If the purpose of the pause is to wait for a calculation, a file, or another program, a fixed delay is only an estimate. The operation might finish earlier, wasting time, or take longer, allowing the macro to continue too soon. Where possible, check for a reliable completion condition rather than guessing how long the operation needs. For instance, a macro that waits for a known cell value can test that value repeatedly with a timeout, instead of always sleeping for five seconds.
Be cautious about adding DoEvents to a tight loop just to keep the interface responsive. It yields control so Excel can process events, but those events can include user actions or other procedures. That can create re-entry or unexpected changes if the macro assumes nothing else can run. Use event-aware waiting only when there is a clear reason and the procedure is designed to handle interruptions.
When Application.OnTime is a better fit
If Excel should remain available while a later macro runs, consider Application.OnTime. Unlike Application.Wait, it schedules a procedure for a future time and returns control instead of holding the current procedure at the wait line. This changes the program structure: the work after the delay must be placed in a separate procedure that Excel can call later.
That approach is useful for a reminder, a scheduled refresh step, or a later action that does not need to continue in the same uninterrupted sequence. It is not a drop-in replacement for “pause here, then continue here.” The scheduled procedure must be available to Excel, and scheduling can be affected by whether Excel is ready to run it. For short, sequential macro logic, Application.Wait is usually simpler; for a workbook that should stay interactive, scheduling may be a better design.
Common problems and fixes
- The macro runs without pausing: Confirm that the wait line is in the procedure being run and that execution reaches it. A conditional branch may skip the line, or a different macro may be selected in the Macro dialog.
- Excel looks frozen: This is a known drawback of waiting inside a procedure. If users need to work during the delay, restructure the task around
Application.OnTimeor another event-based approach rather than expecting the same procedure to pause invisibly. - The delay is not exact: A requested five seconds is not a real-time guarantee. Use a longer margin where the next action depends on an external operation, or check that operation’s completion instead of relying on a fixed delay.
- The macro will not run: Check that the workbook is macro-enabled, that macros are permitted by the organization’s security policy, and that the file comes from a trusted source. Excel for the web cannot execute VBA.
- The code gives a compile error: Verify that the procedure is in a standard module and that the method is spelled
Application.Wait. If you copied code from formatted text, replace typographic punctuation with standard VBA characters.
Choosing the right waiting method
Use Application.Wait when you need a straightforward pause in a short macro and can accept limited responsiveness. Choose Application.OnTime when the workbook should return control to the user and a separate procedure can perform the later action. For waits on files, calculations, or external software, prefer a completion check with a sensible timeout whenever the operation exposes a reliable signal.
A Windows API call such as Sleep is another technique sometimes found in VBA examples, but it adds Windows-specific declarations and can block Excel too. It is not necessary for an ordinary five-second pause, and code using Windows APIs needs extra care for 32-bit and 64-bit Office compatibility. For a simple workbook macro, the built-in Excel method is generally easier to maintain and more portable.
Frequently Asked Questions
Can I use Application.Wait for exactly five seconds?
It requests that the macro wait until a time five seconds in the future, but it does not guarantee that the next instruction will execute at the exact five-second mark. Treat it as an approximate delay, not a precision timer.
Does Application.Wait stop the whole workbook?
It pauses Excel activity while the wait is in effect, so the workbook can seem unresponsive to the user. Background work may behave differently, but do not rely on a user being able to interact normally during the pause.
Can I use Application.Wait in Excel for the web?
No. Excel for the web does not run VBA macros. Open the workbook in the desktop version of Excel to run this VBA procedure.
How do I wait for 10 seconds instead?
Change the interval to TimeSerial(0, 0, 10), keeping the same pattern of adding it to Now. The arguments mean zero hours, zero minutes, and ten seconds.
Can I cancel the pause with Ctrl+Z?
No. Ctrl+Z undoes supported worksheet actions; it does not undo a running macro or serve as a reliable way to cancel a wait. Save a copy before running VBA, and design longer procedures with an intentional way to stop safely if users may need one.
Related
- Data Validation Multiple Selection in Excel: What Works
- Data Validation Interview Questions and Strong Answers
- Excel Data Validation Guidelines for Reliable Spreadsheets
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Access VBA MsgBox: Syntax, Buttons, and ExamplesIn Microsoft Access VBA, use MsgBox to display a message or ask a user a simple question; its…
- Excel VBA Zoom: Set and Manage Worksheet MagnificationTo change the zoom of the active Excel worksheet with VBA, set ActiveWindow.Zoom to a percentage from 10…
- Excel VBA Find Method: Syntax, Examples, and TipsIn Excel VBA, use the Range.Find method to search a specified range and return the first matching cell;…
- VBA Find First Empty Cell in a ColumnTo find the first truly empty cell in column A with VBA, scan from the top and test…
- VBA Delete Row and Shift Up: Excel Macro ExamplesTo delete an entire worksheet row with VBA and move the rows below it up, use Rows(rowNumber).Delete, such…
- Excel Macro to Generate a Chart Automatically in VBAYes. In desktop Excel for Microsoft 365 on Windows, a VBA macro can create a chart from a…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.