Ctrl+Break Won't Work to Stop a Macro

Written by Allen Wyatt (last updated December 23, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Russell is having a problem with Excel, when he runs macros. It seems that all of a sudden Ctrl+Break no longer stops the execution of a macro. Either the macro continues as if he had done nothing or Excel hangs up and he has to close it and start over. Russell checked and clicking the Stop Macro button (parallel line) in the VB menu doesn't work either, so this is not a problem of linkages to keys. He wonders if anyone else experienced this and if there is an easy fix.

This doesn't seem to be a common problem, as far as we can tell. It is possible that there is something errant going on in this particular system. For instance, it is possible that the EnableCancelKey property has been set to disabled, which would stop the normal functioning of Ctrl+Break. This property can be affected by the following macro line:

Application.EnableCancelKey = xlDisabled

This command could have been run in a macro which then did not enable the property. (Perhaps the macro coding either didn't include the enabling or the macro ended abnormally and never got to the command line to enable the property.) It is also possible that the command could have been entered in the immediate window of the VB Editor.

The setting of the property is persistent, and stays with a workbook if the workbook is saved after the setting is changed. You can check the setting by opening the VB Editor and entering the following in the immediate window:

? Application.EnableCancelKey

If you see a 0 displayed, this means that the property has been disabled. You should then enter the following in the immediate window:

Application.EnableCancelKey = xlInterrupt

After doing so, save the workbook. You should also try to track down where the property was initially disabled and make sure that the coding is corrected so you won't have the problem again.

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 (3906) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, 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

Calculating the Last Day in a Week Number

Given a particular week number for a year, you may want to figure out the date of the last day in that week. There is no ...

Discover More

Changing Default Search Settings

Excel provides some great tools for finding information in a worksheet or a workbook. Changing the default settings used ...

Discover More

Self-Deleting Macros

Macros are very powerful, but you may not want them to always be available to a user. Here are some ways you can limit ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Specifying Location for a Message Box

When writing macros, you may want to position a message box at a specific location on the screen. This can't be done in ...

Discover More

Excel Crashes when Running Macros

It can be frustrating when macros don't run as you expect. When it occurs, however, tracking down the cause can be even ...

Discover More

Displaying the "Last Modified" Date

Want to know when a workbook was last modified? Want to put that date within the header of your worksheet? Here's how to ...

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 nine minus 5?

2023-12-23 08:11:30

Jeff Carnohan

I recently learned of the Ctrl-Pause method. It works perfectly in Excel 365. It pops up the debugger dialog box allowing you to choose to cancel or debug. I suspect it works on other versions as well but I can't say for certain.


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.