I first came across this Microsoft Excel vba error back in 2009, when the vba dialog box interrupted macro processing with the message "Code Execution Has Been Interrupted" and it quite literally did my head in.
It’s a weird error because it doesn’t have an error number and in fact it isn’t really an error but rather a bug for which a lot of misinformation existed on the net back then.
The Problem defined.
You’ve written your Excel VBA application and everything’s working fine, then for no apparent reason the following dialog box pops up, you click "Debug" on the dialog box but you cannot find anything wrong with your code.
Maybe it’s a one off and you run the code again, but the message "Code Execution Has Been Interrupted" appears again, oops!
When that happened to me, after a lot of research on the net, I thought I was up a certain creek without a paddle.
Since my application was going to be deployed to my user base, I couldn’t have something as unprofessional as this dialog box popping up randomly.
The code would go into break mode at various parts of the program even though no "break points" or "STOP" commands existed on those lines.
What I think causes it
I can only guess at this, not being a Microsoft Insider, but it seems to me that when you set breakpoints in your code, either by using the "STOP" command or clicking the left sidebar of the code or hitting "ctrl" + "break" to enter break mode during your development process, Microsoft Excel sometimes records this "behind the scenes" and doesn’t clear the breakpoint out of it’s "memory".
So the breakpoint somehow gets hardcoded into your vba module within the file even though there’s no visible breakpoint in your visual basic editor.
The Solution – Clear the hidden break in the code with another "Ctrl + Break"
So when this happens to you, click "Debug" on the Microsoft VBA "Code Execution Interrupted" dialog box, this’ll jump you to the Visual Basic Editor and a particular line of code will be highlighted to show that execution has stopped at that point.
As the compiled vba code in the workbook probably has a hidden breakpoint saved at this point, just hit "Ctrl + Break" on your keyboard (I tend to do Ctrl+Break multiple times).
Sign up below and get notified when new Business Programmer blog or video tutorials are created.
This removes the hidden breakpoint and all you need to do now is save the workbook and your problem is solved, at least for that breakpoint.
If this problem does occur again, most likely you’ve multiple hidden breakpoints in your application.
Just rinse and repeat the above instructions for each instance of "Code Execution Interrupted" until the problem is solved.
Note do not use Application.EnableCancelKey = xlDisabled as this doesn’t solve the problem and in fact ensures that you cannot "Break" into the application if something goes wrong.
Geoff Mitchell says
This seems to work. Thanks
Sean Johnson says
HI Geoff
Glad I could help.
dexter says
worked
White Geared says
Silly bug but thanks a lot for saving me headache.
AAA says
Thank you very much!!! It really helps! You are a Great Guru!
How do you succeed to find out this solution?
Bert says
Tanks for this simple solution. This problem still ocuurs in excel vba 2016 Dutch version.
Greg Moran says
This worked for me – thank you!
Adam says
Worked for me. Thank you
Dev says
Yes, It worked for me.
Thank you so much
Hema Packiriswamy says
Thanks
It worked for me
Sean Johnson says
Thanks Hema, Dev, Adam and Greg for the reply.
Glad to know that this article is useful.
Cheers
Sean
Dorota says
It worked for me too.
Thank you π
Edward says
SHORT AND PROFESSIONAL.
Thanks a lot.
Imran Khan says
very nice article wonderful
Gulam M Shoeb says
Thanks Sean! This was a great help.
Sean Johnson says
Glad I could help, Gulam.
It caused me a lot of pain, back in the day.
Milind says
Thanks a lot, Sean! This trick solved the problem instantly.
I agree that intervention such as the code “Application.EnableCancelKey = xlDisabled” is over doing it a bit.
Minimal solutions work the best.
Thanks a lot.
Migs says
holy cow! i’ve been looking for an answer to this pesky problem. this made my day. thanks so much Sean! π
Sean Johnson says
I know how you feel, it totally ruined my month back in the day.
Lisa says
I was pulling my hair out, thank you for saving me a lot of work.
Patrick says
Whaaawww! This is great! Till now I had to reboot to get rid of this message. Thanks a lot.
Fiona says
Thank you, this worked for me. Solved!
Chris says
Excellent solution, and good point about misinformation around this issue. Excel is not my forte’ but I could lend a hand if you need any database queries written π
Floyd says
Worked like a charm. Thank You
Jessica says
Thank you, worked great
Franklin says
Great, Good solution, this is what I was looking for.
Many thanks.
Solution seeker says
Hi this is Yaried I’ve an excel template constructed with vba program, and it works only in registered computers, this means it automatically closes when someone tries to open in unregistered computer. But I’ve suffered a problem, that they open it with applying ctrl + break to terminate auto execution. Is there some one to help with this problem
Siddartha says
Thank you
Sandy says
Worked efficiently. Thanks
Thomas says
THANK YOU – I can’t believe there are bugs like this still hanging around !!!
It’s working now. Maybe Compile VBAProject would have fixed it. Too late for me to check, it’s already working now.
Coffee / Beer on me if you’re anywhere near St Pauls !
mRdwAYNe says
if the issue comes back over and over again try to set the application.calculation to xlcalculationmanual at the beginning of the line then set back to automatic to the last line of the code. I dont know how to explain this but it works.
Fred B says
Worked, Thx again.
SANTOSH says
THANKS A LOT. it works for me
Charlie says
You saved my life, thanks for sharing the solution to this weird mystery show stopper!
sanju says
Thanks for this info
Tarek says
This solution worked as charm thank you
Jakky Dao says
Hi Sean,
That work for me too. Thanks a lot.
But I do not know how the hidden break point was added into my code since the last time everything work well. Could you or anyone tell me the reason then I can avoid next time?
Thanks,
Cynthia says
Thank YOU! – I had just a small panic attack as I was ready to deploy when this popped up!
Juan says
A question here, if it’s something related to the breakpoints previously used in the vba environnement it shouldn’t be enought to copy the code and paste it in a new workbook to bypass the problem?
I’ve done that but the problem persists… any idea?
DJM says
TY so much.
Kreyson says
ItΒ΄s a perfect article and it works. Thank you so much.
Qadeer says
Thanks! Perfect!
Jai says
Just had to use this while up against a deadline. Thank you!!!!
Serdar Yalçın says
Thank you very much. It works like a charm.
Paul says
Thank you. I have battling this problem for some time now. Restarting Excel never did the trick so I always ended up rebooting.
chandar says
Thanks, its excellent. have problem: excel memory increase and going maximum level in memory, how to reduce or refresh it !!
JHG says
Yes, this worked and was a huge help. Thank you very much!
Ncvp says
OR open VBA editor, select ->debug->clear all breakpoints.
Wilfredo Colon says
Excelent, this work for me. Thx
Miles says
You ledgend Sean.
I just had this exact problem at the end of an important production and I thought “WHAT!”
Will add that I had made a stupid error just beforehand where I forgot to reset a loop counter so crashed my code – I suppose that excel couldn’t clear the breakpoints on the recovered file.
Anyway thank you for bothering to share this online. It would have been very distressing to have my code constantly interrupted by the debugger.
Mufaddal Chittalwala says
Thank you so much Sean Johnson for this information.
I had made a macro couple of weeks back (I am still learning to create macros) tested and was working fine
In the start of this week I thought of just re-checking it to take some reference from it to write a new macro code and suddenly it started giving errors. I was confused why properly tested code giving errors and I thought I made some mistakes in the line and started trouble shooting the code instead of looking for why I was getting interrupted error. And sometimes the macro used to stop any random line which was more frustrating because the code never used to stop at the same line it used to be any random lines
From last 1 week I have been searching like crazy and changed my code so many times to make it work and couldn’t find the solution.
Finally your resolution helped and my code is running perfectly now. I just did Ctrl + Break 10-15 times as you suggested and now all problems resolved thanks to you.
Please let me know if you can help me get the complete start to end book of learning macro or videos that will be really helpful I am still learning but the video I have seems doesn’t have such trouble shooting tips
Thank you so much
Cheers,
Anthony says
Thanks!
I spent hours trying to solve this one.
Chris Hartnell says
Thanks for the solution. It was interesting, yesterday I had that happen in the code of my spreadsheet. Today I opened another spreadsheeet and the same thing happened. So its not just limited to the spreadsheet that it first happened in. It looks like Excel is carrying that into all the spreadsheets until the magical CTRL-Break method fixes it for all!
Sean Johnson says
Glad I could help
Bob says
So happy I found this page instantly when searching. Can see where I could have spent many, many frustrating hours / days finding such / debugging
Bob says
Thank you!
Hamid says
Sean, thanks a lot for your advice.
I was thinking there is an error in my code, but it was a bug as you explained.
Brad Greatbatch says
It works! and I didn’t think it would.
Tsvetomir says
It worked thanks!
Srinivas Reddy says
This works. Thank You
Joe Chez says
De Mucha Ayuda
Gracias
David Rodriguez says
Thank you very much! You saved me ton of aggravation…..Kudos!
Mark Freeman says
Been here before…back again today…hidden break point in code…wreaking havoc on a more or less happy day of VBA programming on Friday 13th! …oh no!! Microsoft is making me tear my last hairs out…every macro…says code execution has stopped!! what?? same code as before…but the gremlins have arrived!! Thanks for putting the gremlins back out of sight…and the world to peace again…:)
Sean Johnson says
Gotta, whack those gremlins π
Dinakar Ramu says
thank you … it worked for me
John says
Excellent, thank you so much! I had something similar in MS Access VBA, but I didn’t realize that same can happen in Excel.
Sean Johnson says
Glad I could help
Daniel says
While this is an old post it is still a live saver! Thanks for writing it. Makes my scripts run just fine again.
Sean Johnson says
I guess the old posts are still relevant since MS isn’t doing much updating on VBA.
Marco says
that work me me as well!! Thank you!!! π
Sean Johnson says
You’re welcome Marco
Fabio says
And it still works in 2020 π
Thank you!
Sean Johnson says
Thanks for letting me know Fabio.
Santhosh says
Thanks, Sean! Your tip has just saved me a lot of aggravation. MS Word, not MS Excel.
Rob says
I can’t believe I spent so many years resetting my computer when the error would popup. Your fix is so simple. Thank you!
Sean Johnson says
You’re welcome
John says
Thanks Sean.
Sean Johnson says
You’re welcome
Chris says
Thanks man, I was at odds with my code
Sean Johnson says
Glad I could help
Erik Oberg says
This article saved my day. Thank you so much :O)
Sean Johnson says
You’re welcome Erik
Drago says
Thanks Sean. So simple but very helpful.
Sean Johnson says
Glad It worked out for you.
Omar says
Thank you Sean! very helpful π
Sean Johnson says
Thanks, Omar
Microsoft doesn’t seem to be interested in fixing this bug, given I came across it over 10 years ago.
Ramana says
Hello sean. thank you for saving my day
at first i thought this issue was caused by my windows or excel
thank you for the solution
Sean Johnson says
You’re welcome, Ramana
Guang says
it works for me too
Sean Johnson says
Great
Jude Johnson says
This has been plaguing me for years! Thank you SO much!!
Sean Johnson says
You’re welcome Jude
Sean Johnson says
Glad I could help, Jude. (Not going to say hey, no waaay….)
Mike says
THANK YOU!
Sean Johnson says
You’re welcome
Sanding says
Million thanks from China.
You saved my hair today:)
Merry Christmas.
Sean Johnson says
Glad I could help, UK China relations by providing a great hair product π
Ken M. says
This just happened to me. Great fix. Thanks!
John S says
wow, was a really easy fix. thanks.
Mark says
Yes this sill works as of May 2021. FYI this worked even when the Application.EnableCancelKey = xlDisabled did not.
Sean Johnson says
Yes Mark
Application.EnableCancelKey = xlDisabled, is no use for this problem
Jacek Witowski says
Thanks π
Anthony says
Wow what an annoying bug! Your solution worked first time so thank you π
Sean Johnson says
Yes it really is, not sure If MIcrosoft have fixed it yet
Stephen D McAuley says
Take the day off! You’re great…!
Sean Johnson says
Where should I go?
NS says
Fantastic!!
Sean Johnson says
It sure is.
Rafael says
YouΒ΄re my hero
Sean Johnson says
Glad I could help
Bob says
This seemed to work.
It happened to me for the first time today.
So it appears that M$ has not fixed it yet.
This interruption could be a show stopper if it persists in a spreadsheet deployed for use by others.
They can be quick to throw out the baby with the bath water if they can point to anything and declare, “It doesn’t work.”
I doubt that M$ will fix it.
They are starting to embrace Python.
I suspect this will mean the end of VBA in a future “update” of Excel — and M$ will leave yet more permanently broken software in their wake.
Sean Johnson says
I don’t see VBA going away any time soon, too many corporate spreadsheets will stop working, but yes in the future they may prioritise javascript or python.
pan f chon says
Saved me!!!
It really works!
Thank you very much!
J says
Thanks. Nice work!