Ctrl+Break Won't Work to Stop a Macro

by Allen Wyatt
(last updated September 7, 2013)

2

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 properlty.) 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.

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

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

Setting the Wrapping Default for Objects

Want to have objects such as text boxes and shapes always appear using some formatting you like? Here are some ideas on ...

Discover More

Using AutoCorrect

The AutoCorrect feature in Excel is a great tool for quickly entering information. Here's an explanation of the feature and a ...

Discover More

Increasing Undo Levels

Excel maintains a record of most of the commands you execute so that you can later "undo" those commands, if desired. It is ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

MORE EXCELTIPS (RIBBON)

Hiding Macros

Need to hide some macros in your workbook? There are three ways you can do it, as covered in this discussion.

Discover More

Making Modal Dialog Boxes Appear in Front of Workbooks

Perhaps the most common way of communicating with programs is through the use of dialog boxes. We expect dialog boxes to be ...

Discover More

Debugging a Macro

Part of writing macros is to make sure they work as you expect. This involves a process known as debugging. Here's how you ...

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 for this tip:

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 3 - 0?

2013-09-09 10:13:58

Jaker

I have run into this as well. Some of my macros do heavy calculating through formulas and if I try to stop during the calculation of a formual it doesn't work. As soon as the calculation is completed I can stop it as long as I hit break before it moves to the next formula.


2013-09-09 01:20:36

Peter Bedson

I have had similar problems - in the end I stuck a line of code at the begining of the offending macro turning on the interrupt key. I never did find out how it was getting disabled - maybe if you find out the value of the built in xlDisabled constant is that would give a clue. I have also found that when you run a macro that has a time consuming action (like sorting a big range or shelling into a different application) then it appears that Ctrl-Break does not work as once it kicks the action off control is not returned to the maacro until (and unless) it finishes hence Ctrl-Break has no effect.


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.

Links and Sharing