VBA & Macro Problems

How Do DoEvents and Application.Wait Work in Excel VBA Chart Animation?

Aamir Naveed AkramAamir Naveed Akram Dec 2, 2026 868 views

Question details

Understand how DoEvents and Application.Wait affect an Excel VBA chart animation.

How Do DoEvents and Application.Wait Work in Excel VBA Chart Animation?
Product
Microsoft Excel
Device & OS
not provided
Scenario
A VBA loop updates cells that supply data to a chart and needs to display each change at a controlled pace.
Observed behavior
DoEvents yields control so Excel can process pending events, while Application.Wait pauses the macro and most Excel interaction for a specified time.
Before you start

Make sure the chart uses the cells your macro will update. Open the VBA editor and check that macros are enabled for the workbook before running an example.

Solution 1Recommended

Use DoEvents to Refresh the Chart and Wait to Control Speed

Use this approach when a VBA loop should show each chart update before pausing between frames.

DoEvents temporarily yields control to the operating system and returns to the macro after pending events are processed. Application.Wait pauses the macro until a specified time; background recalculation and printing may continue.

Because DoEvents can allow other events to run, avoid starting the same macro again while it is already running.

1
Open the VBA editor

In Excel, open the Developer tab and select Visual Basic, then choose Insert > Module. If the Developer tab is hidden, open the VBA editor with the shortcut available on your system.

2
Add an animation loop

Paste this example into the module. Replace Sheet1 with the worksheet name and A1 with a cell used by your chart: Sub AnimateChart() Dim i As Long Application.ScreenUpdating = True For i = 1 To 10 Worksheets("Sheet1").Range("A1").Value = i Worksheets("Sheet1").Calculate DoEvents Application.Wait Now + TimeValue("00:00:01") Next i End Sub

3
Run and adjust the macro

In Excel, select Developer > Macros, choose AnimateChart, and select Run. Change the loop values or the Wait duration to suit the animation; remove the Wait line if no deliberate pause is needed.

Use DoEvents to Refresh the Chart and Wait to Control Speed
Wait is not a refresh command: Use DoEvents after updating and calculating the chart data to give Excel an opportunity to repaint. Wait controls the delay but does not itself ensure that the chart refreshes.
Free Microsoft Office alternative

Work with Spreadsheet Charts in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and Microsoft Office format compatibility for easier migration. The Excel-specific VBA behavior described here must be tested separately if you move a macro-enabled workbook.

Create and edit spreadsheet charts through a familiar interfaceOpen and edit Microsoft Excel formats such as XLSX and XLSUse a lightweight office suite with a free optionMove between compatible Office documents with a familiar workflow
QA img-9

Frequently Asked Questions

Does DoEvents stop a VBA macro?

No. DoEvents temporarily yields control to process pending events, then execution returns to the next statement in the macro.

Why doesn't Application.Wait refresh my chart?

Application.Wait pauses the macro rather than explicitly refreshing the chart. After updating the source cell, calculate the relevant worksheet and call DoEvents before the Wait statement.

Can Excel do anything while Application.Wait is running?

Most Excel interaction is suspended during the wait, but background recalculation and printing may continue.

Can DoEvents cause a macro to run twice?

DoEvents can let pending events or user actions run before the current macro finishes. Prevent the same procedure from being started again, for example by using a running-state flag.