Macro, while Running, Stops Excel from Responding

Written by Allen Wyatt (last updated August 12, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021


3

When Dave writes a macro that must process a lot of information in a For...Next loop, he always uses the status bar to indicate progress. Typically, he'll have a message displayed there such as "Processing row X of Y." When "Y" is a large value (the top end of the For...Next loop), Excel often stops updating the status bar and displays something like "Not Responding" in Excel's title bar. The macro is still running, though, and when it completes, Excel starts responding and everything works like it should. Dave wonders how he can make Excel stop behaving in this manner and, instead, display the status bar updates like he wants.

This behavior seems to occur when it appears to Windows that Excel has stopped responding. (It is Windows, after all, that is responsible for what appears in a program's title bar.) I was able to reproduce the behavior quite easily if I have multiple programs open in Windows and I click to another program window while Excel is chunking through a long macro. Essentially, if Excel is busy performing the macro or it cannot keep up in asking Windows to update the status bar, then it does, indeed appear like Excel has stopped responding.

There are two possible approaches that can be used. First, you could use the DoEvents command within the loop. Normally this is used to instruct the macro to pay attention to anything that is in the events queue, such as when someone presses the keyboard. It is equivalent to forcing Excel to "look up" from the macro on which it is working and to communicate with Windows. This would, necessarily, let Windows know that Excel really is responsive and allow the updates to the status bar to occur. You could even put the command right after updating the status bar:

Application.StatusBar = "Processing row " & X & " of " & Y
DoEvents

The other thing to try is to simply not update the status bar as much. If the upper end of your loop is very large, then it might be better to calculate a percentage and update the status bar when some portion of the total is completed—perhaps every 5% or 10% of the total. This would mean the status bar only needs to be updated 10 or 20 times during the loop, rather than hundreds or thousands of times. This may mean that Windows can keep up with the requests to update the status bar and, as a bonus, your macro may run faster because it doesn't have to update the status bar as often.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13341) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Working with E-mailed Documents

Ding! You've got mail. That mail has a Word document attached to it. Before you rush off and open that document, take a ...

Discover More

Exporting Latitude and Longitude

A handy way to store latitude and longitude values in Excel is to treat them as regular time values. When it comes around ...

Discover More

Uncovering and Removing Links

Excel allows you to reference data in other workbooks by establishing links to that data. If you later want to get rid of ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More ExcelTips (ribbon)

Delimited Text-to-Columns in a Macro

The Text-to-Columns tool is an extremely powerful feature that allows you to divide data in a variety of ways. Excel even ...

Discover More

Using InputBox to Get Data

Need your macro to get some input from a user? The standard way to do this is with the InputBox function, described in ...

Discover More

Displaying the Selected Cell's Address

Need to know the address of the cell that is currently selected? The function and macro highlighted in this tip will come ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven more than 7?

2025-08-12 10:18:51

jamies

Sometimes pounding on the Esc key will cause a "break" in the processing

There is the facility to have a macro break into "Debug" mode - but you should ensure the developer tab is shown on the ribbon

And - you can always use the messagebox - in association with status updates -
invite the screen viewer to indicate when the message input facility should next be presented.

Those do, however require the excel session be running with the display being active, rather than as a background task.
and - ideally there should be an option/entry to bethe "debug" now option,
Debug.Assert False

and a just get on with it till it ends option

and there is the ask every nnnnn lines mode where the user enters the nnnnn into the messagebox, to set a loop


And - for "professional debugging -

have a bit of code to check for the existence of a logging file, specific name & location
with a specific content as the first line - just so the process knows it is it's logging file for output
that to have a second line giving:

number of the data blocks/rows etc. to process before writing to the log file
number of blocks/rows of data processing to be logged,
action to take at that point of done all them, - ask how many more ?
level of information to post to the log -
row/block number in the input?, with the identifying keys?, and the data, and row/block number generated in the output ? or id of entry updated ?

you get the concept -

that allows a remote operation for a client to have problem diagnostics created -
written (appended) to the log file wit the creation of that file being under the user's, or IT support staff control, and it's renaming, and moving (sending) to a location for you to view it in it's entirety,
or for them to extract whatever entries seem to cause the glitch in the processing.

And for those with unix utilities - there is the Unix/Linux tail command

Also - do remember autosave should be at intervals that are long enough for the block of entries, or all the process to be performed.


2025-08-12 06:52:48

Brian

Another approach is to create a look-alike progress bar. This can be achieved by having a wide(ish) cell or a merged row with a conditional format of 'Data Bar' and a minimum value of 0 and a maximum of whatever equates to 100% of the macro loops. The format of the cell needs to be set to "Processing Row:";;; and the next cells to the right set to the current progress, ' of ' and the maximum. I have my data bar set to a solid bar, solid fill, left to right and green. I have 2 other conditional formats - one that set the background of the 'slider' to red if the number processed is > 0, then as soon as the macro starts it write a value to the status bar cell, so the bar appears green on red, with the green bit gradually obscuring the red. The second conditional sets the cell font color to white if the cell value is 0. When the macro finishes it sets the bar value to 0, so the text 'vanishes'.

If the macro is running with screenupdating set to false, it has to be set to true just before the new number is written to the bar cell and then set back to false immediately after.


2020-12-12 11:12:33

J. Woolley

My Excel Toolbox includes the freely available ProgressBar_Text and ProgressBar_Form procedures. ProgressBar_Text uses the status bar. ProgressBar_Form includes a user form. I like to use the latter with Lightbox_Initiate to obscure the Excel window while a long macro is running, followed by Lightbox_Terminate. See https://sites.google.com/view/MyExcelToolbox/


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.