Fix a Slow Excel VBA Loop When Writing to Cells
Question details
Determine why an Excel VBA loop that writes values to approximately 40 cells has suddenly become slow and improve its performance.

- 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.
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.
Reduce Excel Updates During the VBA Loop
Use this approach when repeated screen refreshes, recalculations, or event procedures may be slowing each cell write.
Open the workbook in Excel, then select Developer > Visual Basic. In the VBA editor, open the module containing the slow loop.
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.
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.
Run the macro from Developer > Macros and compare its execution time. Confirm that formulas, events, and screen updates behave as expected afterward.

Check Page Breaks, Formulas, Events, and Add-ins
Use these checks to find workbook or environment changes that can make even a short loop slow.
Write Larger Excel Ranges with a VBA Array
Use a single range assignment to reduce repeated interactions with Excel when writing many values.
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.

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.




