Cant execute code in break mode lỗi vba excel gì năm 2024

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.

Cant execute code in break mode lỗi vba excel gì năm 2024

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.

Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Cant execute code in break mode lỗi vba excel gì năm 2024


Well-known Member

Joined Sep 30, 2005 Messages 1,227 Office Version

  1. 2013
  2. 2010 Platform
  3. Windows
  • 2

Hi - Welcome to the board

Does this happen as soon as you open the workbook?

IE: Open Workbook >> Click Button >> Error Message?

Or is it possible you have been debugging it and tried to run it again?

If the latter is the case you need to stop the code by pressing the Stop button at the top of the VBE (Play / Pause / Stop).

Other than that, I've never seen that before ..

Cant execute code in break mode lỗi vba excel gì năm 2024


MrExcel MVP

Joined Oct 12, 2006 Messages 44,061

  • 3

Welcome to the board.

1. Can't execute code in break mode means that some code previously errored, and you clicked Debug. VBA is now in a Paused Mode. It can't start a new code until you either resolve the error and resume the previous code, or STOP the previous code that errored. In the VBA window, you should see a Stop and a Play button (like those of a CD Player) on the toolbar. Press Play to try to Resume the code that priviously failed, or press Stop to END the previous code that failed.

2. As for the problem, If that's the line highlighted, my first guess would be that the Sheet ResourcePlanW either does not exist, or is hidden. If it doesn't exist, well, you need to make it exist, or change the sheetname the code is trying to select. If it's just hidden, you can either manually unhide it, or put this line before the highlighted line.

Sheets("ResourcePlanW").Visible = True

Cant execute code in break mode lỗi vba excel gì năm 2024


MrExcel MVP

Joined Oct 12, 2006 Messages 44,061

  • 4

Actually, I can guess the sheet does exist and is just hidden. Because previous lines referred to the sheet without selecting it. So it must exist.

CaN'T execute code in Break Mode là lỗi gì?

Nguyên nhân của lỗi này là do VBA đã chạy và mắc lỗi trước đó. Khi đó VBA ở trong chế độ Break Mode (chế độ ngắt, không hoạt động tiếp). Khi chạy 1 macro khác (hoặc vẫn macro đó) sẽ không được thực hiện và xuất hiện báo lỗi này.