• Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • VBA Programming
  • Open-Libre Office
  • Web Stuff
  • Videos
    • VBA Articles
    • LibreOffice And Open Office
  • Excel VBA Glossary
  • About
  • Contact

My Best Stuff Is In The Newsletter

No charge. No spam. Unsubscribe anytime.

Submitting...

Code Execution Has Been Interrupted – The best fix to this Excel VBA Problem

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.

Code Execution Has Been Interrupted

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.

Submitting…

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.

If you found this article really helpful, then consider grabbing me a coffee, it takes a lot of work and expense to keep this site going, the more caffeine I have the harder I can work.

And if you do grab me a coffee, thanks for your support πŸ˜‰

Filed Under: Excel, Most Popular, VBA Tagged With: Excel VBA Macros

Reader Interactions

Comments

  1. Geoff Mitchell says

    19/03/2016 at 20:23

    This seems to work. Thanks

    Reply
    • Sean Johnson says

      19/03/2016 at 21:18

      HI Geoff

      Glad I could help.

      Reply
      • dexter says

        21/02/2021 at 11:21

        worked

        Reply
      • White Geared says

        29/06/2021 at 07:46

        Silly bug but thanks a lot for saving me headache.

        Reply
    • AAA says

      01/11/2018 at 16:01

      Thank you very much!!! It really helps! You are a Great Guru!
      How do you succeed to find out this solution?

      Reply
    • Bert says

      29/04/2020 at 21:15

      Tanks for this simple solution. This problem still ocuurs in excel vba 2016 Dutch version.

      Reply
  2. Greg Moran says

    16/06/2016 at 16:54

    This worked for me – thank you!

    Reply
  3. Adam says

    29/06/2016 at 11:59

    Worked for me. Thank you

    Reply
  4. Dev says

    14/07/2016 at 16:27

    Yes, It worked for me.

    Thank you so much

    Reply
  5. Hema Packiriswamy says

    19/08/2016 at 06:46

    Thanks
    It worked for me

    Reply
    • Sean Johnson says

      19/08/2016 at 07:11

      Thanks Hema, Dev, Adam and Greg for the reply.

      Glad to know that this article is useful.

      Cheers

      Sean

      Reply
  6. Dorota says

    11/10/2016 at 12:51

    It worked for me too.
    Thank you πŸ™‚

    Reply
  7. Edward says

    14/10/2016 at 22:39

    SHORT AND PROFESSIONAL.
    Thanks a lot.

    Reply
  8. Imran Khan says

    18/11/2016 at 12:54

    very nice article wonderful

    Reply
  9. Gulam M Shoeb says

    24/11/2016 at 11:08

    Thanks Sean! This was a great help.

    Reply
    • Sean Johnson says

      25/11/2016 at 19:49

      Glad I could help, Gulam.
      It caused me a lot of pain, back in the day.

      Reply
  10. Milind says

    15/12/2016 at 08:33

    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.

    Reply
  11. Migs says

    20/12/2016 at 23:11

    holy cow! i’ve been looking for an answer to this pesky problem. this made my day. thanks so much Sean! πŸ™‚

    Reply
    • Sean Johnson says

      21/12/2016 at 00:18

      I know how you feel, it totally ruined my month back in the day.

      Reply
  12. Lisa says

    16/06/2017 at 16:04

    I was pulling my hair out, thank you for saving me a lot of work.

    Reply
  13. Patrick says

    03/08/2017 at 08:07

    Whaaawww! This is great! Till now I had to reboot to get rid of this message. Thanks a lot.

    Reply
  14. Fiona says

    17/08/2017 at 11:21

    Thank you, this worked for me. Solved!

    Reply
  15. Chris says

    31/08/2017 at 20:59

    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 πŸ™‚

    Reply
  16. Floyd says

    22/11/2017 at 13:11

    Worked like a charm. Thank You

    Reply
  17. Jessica says

    07/12/2017 at 14:21

    Thank you, worked great

    Reply
  18. Franklin says

    29/12/2017 at 05:21

    Great, Good solution, this is what I was looking for.

    Many thanks.

    Reply
  19. Solution seeker says

    07/01/2018 at 08:20

    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

    Reply
  20. Siddartha says

    09/01/2018 at 09:40

    Thank you

    Reply
  21. Sandy says

    05/02/2018 at 15:10

    Worked efficiently. Thanks

    Reply
  22. Thomas says

    07/02/2018 at 11:15

    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 !

    Reply
  23. mRdwAYNe says

    23/02/2018 at 03:16

    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.

    Reply
  24. Fred B says

    22/03/2018 at 17:53

    Worked, Thx again.

    Reply
  25. SANTOSH says

    17/04/2018 at 18:22

    THANKS A LOT. it works for me

    Reply
  26. Charlie says

    23/04/2018 at 04:18

    You saved my life, thanks for sharing the solution to this weird mystery show stopper!

    Reply
  27. sanju says

    27/06/2018 at 05:27

    Thanks for this info

    Reply
  28. Tarek says

    29/06/2018 at 03:51

    This solution worked as charm thank you

    Reply
  29. Jakky Dao says

    03/07/2018 at 07:38

    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,

    Reply
  30. Cynthia says

    12/07/2018 at 18:10

    Thank YOU! – I had just a small panic attack as I was ready to deploy when this popped up!

    Reply
  31. Juan says

    13/07/2018 at 19:55

    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?

    Reply
  32. DJM says

    25/07/2018 at 05:13

    TY so much.

    Reply
  33. Kreyson says

    31/07/2018 at 05:37

    ItΒ΄s a perfect article and it works. Thank you so much.

    Reply
  34. Qadeer says

    09/08/2018 at 04:16

    Thanks! Perfect!

    Reply
  35. Jai says

    22/08/2018 at 21:12

    Just had to use this while up against a deadline. Thank you!!!!

    Reply
  36. Serdar YalΓ§Δ±n says

    28/08/2018 at 18:56

    Thank you very much. It works like a charm.

    Reply
  37. Paul says

    18/09/2018 at 06:23

    Thank you. I have battling this problem for some time now. Restarting Excel never did the trick so I always ended up rebooting.

    Reply
  38. chandar says

    13/10/2018 at 18:06

    Thanks, its excellent. have problem: excel memory increase and going maximum level in memory, how to reduce or refresh it !!

    Reply
  39. JHG says

    21/10/2018 at 06:44

    Yes, this worked and was a huge help. Thank you very much!

    Reply
  40. Ncvp says

    01/11/2018 at 12:50

    OR open VBA editor, select ->debug->clear all breakpoints.

    Reply
  41. Wilfredo Colon says

    19/11/2018 at 15:41

    Excelent, this work for me. Thx

    Reply
  42. Miles says

    19/12/2018 at 11:09

    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.

    Reply
  43. Mufaddal Chittalwala says

    21/12/2018 at 06:00

    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,

    Reply
  44. Anthony says

    18/03/2019 at 19:59

    Thanks!

    I spent hours trying to solve this one.

    Reply
  45. Chris Hartnell says

    29/03/2019 at 14:14

    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!

    Reply
    • Sean Johnson says

      29/05/2020 at 15:19

      Glad I could help

      Reply
  46. Bob says

    21/04/2019 at 15:15

    So happy I found this page instantly when searching. Can see where I could have spent many, many frustrating hours / days finding such / debugging

    Reply
    • Bob says

      21/04/2019 at 15:16

      Thank you!

      Reply
  47. Hamid says

    28/04/2019 at 00:52

    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.

    Reply
  48. Brad Greatbatch says

    18/07/2019 at 03:49

    It works! and I didn’t think it would.

    Reply
  49. Tsvetomir says

    02/08/2019 at 08:07

    It worked thanks!

    Reply
  50. Srinivas Reddy says

    09/08/2019 at 14:37

    This works. Thank You

    Reply
  51. Joe Chez says

    15/08/2019 at 20:29

    De Mucha Ayuda
    Gracias

    Reply
  52. David Rodriguez says

    19/08/2019 at 18:09

    Thank you very much! You saved me ton of aggravation…..Kudos!

    Reply
  53. Mark Freeman says

    13/09/2019 at 20:44

    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…:)

    Reply
    • Sean Johnson says

      18/11/2020 at 12:22

      Gotta, whack those gremlins πŸ˜‰

      Reply
  54. Dinakar Ramu says

    20/09/2019 at 08:11

    thank you … it worked for me

    Reply
  55. John says

    07/11/2019 at 21:32

    Excellent, thank you so much! I had something similar in MS Access VBA, but I didn’t realize that same can happen in Excel.

    Reply
    • Sean Johnson says

      24/03/2020 at 17:01

      Glad I could help

      Reply
  56. Daniel says

    02/12/2019 at 12:35

    While this is an old post it is still a live saver! Thanks for writing it. Makes my scripts run just fine again.

    Reply
    • Sean Johnson says

      24/03/2020 at 17:03

      I guess the old posts are still relevant since MS isn’t doing much updating on VBA.

      Reply
  57. Marco says

    06/12/2019 at 13:59

    that work me me as well!! Thank you!!! πŸ™‚

    Reply
    • Sean Johnson says

      24/03/2020 at 17:02

      You’re welcome Marco

      Reply
  58. Fabio says

    20/02/2020 at 17:52

    And it still works in 2020 πŸ˜€
    Thank you!

    Reply
    • Sean Johnson says

      24/03/2020 at 17:00

      Thanks for letting me know Fabio.

      Reply
  59. Santhosh says

    29/03/2020 at 13:22

    Thanks, Sean! Your tip has just saved me a lot of aggravation. MS Word, not MS Excel.

    Reply
  60. Rob says

    04/05/2020 at 17:35

    I can’t believe I spent so many years resetting my computer when the error would popup. Your fix is so simple. Thank you!

    Reply
    • Sean Johnson says

      29/05/2020 at 15:18

      You’re welcome

      Reply
  61. John says

    19/05/2020 at 19:56

    Thanks Sean.

    Reply
    • Sean Johnson says

      03/07/2023 at 12:52

      You’re welcome

      Reply
  62. Chris says

    19/06/2020 at 00:43

    Thanks man, I was at odds with my code

    Reply
    • Sean Johnson says

      25/07/2020 at 01:25

      Glad I could help

      Reply
  63. Erik Oberg says

    02/08/2020 at 13:36

    This article saved my day. Thank you so much :O)

    Reply
    • Sean Johnson says

      24/08/2020 at 14:48

      You’re welcome Erik

      Reply
  64. Drago says

    04/08/2020 at 19:46

    Thanks Sean. So simple but very helpful.

    Reply
    • Sean Johnson says

      24/08/2020 at 14:47

      Glad It worked out for you.

      Reply
  65. Omar says

    07/09/2020 at 14:42

    Thank you Sean! very helpful πŸ˜€

    Reply
    • Sean Johnson says

      08/09/2020 at 13:02

      Thanks, Omar
      Microsoft doesn’t seem to be interested in fixing this bug, given I came across it over 10 years ago.

      Reply
  66. Ramana says

    15/09/2020 at 05:29

    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

    Reply
    • Sean Johnson says

      18/11/2020 at 12:20

      You’re welcome, Ramana

      Reply
  67. Guang says

    14/10/2020 at 08:55

    it works for me too

    Reply
    • Sean Johnson says

      18/11/2020 at 12:19

      Great

      Reply
  68. Jude Johnson says

    26/11/2020 at 05:24

    This has been plaguing me for years! Thank you SO much!!

    Reply
    • Sean Johnson says

      28/11/2020 at 00:06

      You’re welcome Jude

      Reply
    • Sean Johnson says

      30/12/2020 at 14:27

      Glad I could help, Jude. (Not going to say hey, no waaay….)

      Reply
  69. Mike says

    30/11/2020 at 09:43

    THANK YOU!

    Reply
    • Sean Johnson says

      30/12/2020 at 14:26

      You’re welcome

      Reply
  70. Sanding says

    24/12/2020 at 04:32

    Million thanks from China.
    You saved my hair today:)
    Merry Christmas.

    Reply
    • Sean Johnson says

      30/12/2020 at 14:26

      Glad I could help, UK China relations by providing a great hair product πŸ˜‰

      Reply
  71. Ken M. says

    04/02/2021 at 20:46

    This just happened to me. Great fix. Thanks!

    Reply
  72. John S says

    25/02/2021 at 20:10

    wow, was a really easy fix. thanks.

    Reply
  73. Mark says

    17/05/2021 at 22:03

    Yes this sill works as of May 2021. FYI this worked even when the Application.EnableCancelKey = xlDisabled did not.

    Reply
    • Sean Johnson says

      18/05/2021 at 00:24

      Yes Mark
      Application.EnableCancelKey = xlDisabled, is no use for this problem

      Reply
  74. Jacek Witowski says

    31/05/2021 at 03:29

    Thanks πŸ™‚

    Reply
  75. Anthony says

    23/07/2021 at 07:42

    Wow what an annoying bug! Your solution worked first time so thank you πŸ™‚

    Reply
    • Sean Johnson says

      03/07/2023 at 12:54

      Yes it really is, not sure If MIcrosoft have fixed it yet

      Reply
  76. Stephen D McAuley says

    08/09/2021 at 20:37

    Take the day off! You’re great…!

    Reply
    • Sean Johnson says

      03/07/2023 at 12:53

      Where should I go?

      Reply
  77. NS says

    09/09/2021 at 08:37

    Fantastic!!

    Reply
    • Sean Johnson says

      03/07/2023 at 12:53

      It sure is.

      Reply
  78. Rafael says

    03/07/2023 at 11:51

    YouΒ΄re my hero

    Reply
    • Sean Johnson says

      03/07/2023 at 12:52

      Glad I could help

      Reply
  79. Bob says

    09/09/2023 at 17:46

    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.

    Reply
    • Sean Johnson says

      03/02/2024 at 22:38

      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.

      Reply
  80. pan f chon says

    19/10/2023 at 06:02

    Saved me!!!
    It really works!

    Thank you very much!

    Reply
  81. J says

    21/03/2024 at 15:00

    Thanks. Nice work!

    Reply

Leave a Reply to Franklin Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Free Training Videos

Make VBA Listbox Work as Database Grid

Image

Ulitmate Excel VBA Advanced Filter Tutorial

Click video and press f for full screen or watch on YouTube

Dynamically Link Images to LibreOffice Base Form

Click video and press f for full screen or watch on YouTube

Create Database with LibreOffice Base

Click video and press f for full screen or watch on YouTube

Create VBA Form In Excel

Click video and press f for full screen or watch on YouTube

Affiliate Disclamer

We hope you love the products we recommend! Just so you know, we may collect a share of sales or other compensation from the links on this page.
Thank you if you use our links, we really appreciate it!

Terms Of Service | Privacy Statement | Copyright Β© 2024 BusinessProgrammer.com.