VBA & Macro Problems

Fix a Slow Excel VBA Loop When Writing to Cells

Huma Ashraf ChHuma Ashraf Ch Nov 25, 2026 868 views

Question details

Determine why an Excel VBA loop that writes values to approximately 40 cells has suddenly become slow and improve its performance.

Fix a Slow Excel VBA Loop When Writing to Cells
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user runs an existing VBA macro that writes values to a small range of cells.
Observed behavior
The loop runs unusually slowly even though the code has not changed.
Before you start

Identify the macro and the worksheet range it changes, and note whether the slowdown occurs in one workbook or others. Check whether the workbook contains change-event procedures or formulas that recalculate when those cells are updated.

Solution 1Recommended

Reduce Excel Updates During the VBA Loop

Use this approach when repeated screen refreshes, recalculations, or event procedures may be slowing each cell write.

1
Open the macro

Open the workbook in Excel, then select Developer > Visual Basic. In the VBA editor, open the module containing the slow loop.

2
Save and adjust application settings

Before the loop, store the current values of Application.ScreenUpdating, Application.Calculation, Application.EnableEvents, and, if needed, Application.DisplayAlerts. Set ScreenUpdating and EnableEvents to False and Calculation to xlCalculationManual while the loop runs.

3
Restore settings on exit

Add an error-handling cleanup section to the macro that restores each saved setting on both normal completion and error. Restore the original calculation mode while events are still disabled, then restore EnableEvents; recalculate if the workbook needs updated formula results.

4
Test the loop again

Run the macro from Developer > Macros and compare its execution time. Confirm that formulas, events, and screen updates behave as expected afterward.

Reduce Excel Updates During the VBA Loop
Use caution with alerts: Set DisplayAlerts to False only if the macro needs it: Excel may choose default responses to prompts. Restore its original value in the cleanup section.
Free Microsoft Office alternative

Work with Excel Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and compatibility with common Excel formats, making it easier to move everyday spreadsheet work. It does not fix Excel's VBA performance, and macro compatibility should be tested separately.

Open and edit spreadsheets in a familiar interfaceCompatible with common Microsoft Excel formats, including XLSXUse a lightweight suite for everyday spreadsheet tasksMove spreadsheet work between Office applications with common file formats
microsoft office alternative - wps office

Frequently Asked Questions

Why can a loop over only 40 cells be slow?

Each write can trigger recalculation, worksheet events, or other workbook activity. Inspect Worksheet_Change in Developer > Visual Basic and test with calculation and events temporarily disabled.

How do I turn off page-break display in Excel?

Go to File > Options > Advanced and, under display options for the affected worksheet, clear Show page breaks if the option is available.

Will disabling events stop worksheet change macros?

Yes. Setting Application.EnableEvents to False prevents Excel events from firing while it is disabled. Save the original setting and restore it in an error-handling cleanup section.

When should I use an array instead of writing cells one by one?

An array is especially useful for larger ranges because you can fill values in memory and assign them to Range.Value once. Its dimensions must match the target range.

Can WPS Office fix a slow Excel VBA macro?

No. WPS Office is an alternative for spreadsheet work, not a fix for Excel's VBA performance. Test any workbook's macro compatibility separately before relying on it in another application.