Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot execute macro in Break Mode

I am trying to write a simple macro to add 1 to the cell's current value:

Sub add()
    MsgBox Selection.Value
    Selection.Value = Selection.Value + 1
End Sub

I receive the following error message when I click a (numeric) cell and try to run the macro:

Cannot Execute in Break Mode

What am I missing?

like image 440
mike Avatar asked Feb 18 '13 10:02

mike


People also ask

How do I get my macro out of break mode?

To exit from break mode, choose Reset from the Run menu. Note that the caption in the titlebar of the VBA IDE indicates which mode is currently active. In particular, the caption contains the word “[running]” when in run mode and “[break]” when in break mode.

Why are macros not running?

If you have shared a macro-enabled workbook with another user and the macros subsequently stopped working, it's possible that they accidentally re-saved it as an ordinary workbook that can't contain macros. You can see more about the different file types that Excel can save in our completely free Basic Skills E-book.

How do you fix macros not working?

Click the File tab, and then click Options at the very bottom of the left bar. On the left-side pane, select Trust Center, and then click Trust Center Settings… . In the Trust Center dialog box, click Macro Settings on the left, select Enable all macros and click OK.


1 Answers

You are already executing a macro and somehow stopped its execution (e.g. due to an unhandled error or because you pressed Ctrl-Break during the execution). In this state, you cannot execute another macro.

In the Visual Basic Editor, you need to press the Stop button: enter image description here

Then you can run the macro.

If you want to understand where the current execution is stopped, right click the code and select Show Next Statement. If you then press F8 you can step through the code. F5 continues the execution.

like image 111
Peter Albert Avatar answered Sep 18 '22 12:09

Peter Albert