excel VBA break execution when there's no brea

2020-06-30 05:10发布

I'm just noticing that on my laptop (Dell XPS 15z) there's no BREAK key (no dedicated number keypad). I'm running the debugger step-by-step and then when all seems fine, I just let it play out. However, it's running in an infinite loop and now I'm realizing there's no way to stop it without the break key!!!!

Is this a bad joke? I had to reboot the computer; is there a more graceful way??

Thanks.

12条回答
一纸荒年 Trace。
2楼-- · 2020-06-30 05:48

None of the above answers work for me.

I did how ever find this, it's not perfect since you need to keep ALT pressed and then a keys twice. On top of that it's depended on what language your Excel is set to.

In an English Excel you'd use ALT + R + R in German you need to use ALT + U + R

查看更多
萌系小妹纸
3楼-- · 2020-06-30 05:48

I found a way round this, opened another instance of Excel and another spreadsheet, then opened the VBA editor from there and it showed as "running" so I could click the stop button

查看更多
放我归山
4楼-- · 2020-06-30 05:49

Solution #1 (It works most of the time): When some particular keys (Pause, Break or ScrLk) are missing on the keyboard and pressing Esc 2, 3 or multiple times doesn't stop the macro too.

Step #01: If your keyboard does not have a specific key, please do not worry and open the 'OnScreen Keyboard' from Windows Utilities by pressing Win + U.

Step #02: Now, try any of the below option and of them will definitely work depending on your system architecture i.e. OS and Office version

  • Ctrl + Pause
  • Ctrl + ScrLk
  • Esc + Esc (Press twice consecutively)

You will be put into break mode using the above key combinations as the macro suspends execution immediately finishing the current task. For eg. if it is pulling the data from the web then it will halt immediately before executing any next command but after pulling the data, following which one can press F5 or F8 to continue the debugging.


When Solution #1 doesn't work or you need a permanent solution then try adding a new KEY to the Registry. (I am running Win 10 Creators Update on Dell 3530 Inspiron Laptop)

Disclaimer: Please only make changes to Windows Registry at your own risk and it is advisable only if you are windows administrator or have prior experience in the changing the key values in the registry.

You can also look for Solution #2 which use accessibility keyboard Win + U

Solution #2: 1) Click the START, then type REGEDIT into the search box. This will start the registry editor.

2) Explore the Registry, expanding each element HKEY_LOCAL_MACHINE -SYSTEM -Current Control Set - Control - Keyboard Layout

Click on the Scancode Map, and EDIT the key values to match that shown below. i.e. to have values of : 00,00,00,00,00,00,00,00,02,00,00,00,46,e0,44,00,00,00,00,00

Once Done you will need to reboot your laptop, but after that, you can use as the pause/Break Key.

To understand it in detail and customize it as per your needs, please refer this link: KeyBoard Scancodes

查看更多
欢心
5楼-- · 2020-06-30 05:50

I have an HP laptop and this works when I want to break after a msgbox, hold fn+ctrl and click right shift key (has pause on it as well) then respond to msgbox and code will break.

查看更多
贼婆χ
6楼-- · 2020-06-30 05:53

I have a Dell Precision without a Pause/Break key but there is a replacement for that: Fn + B, so:

- Fn + B == Pause (pause execution);
- Ctrl + Fn + B == Break (break execution);
- Win + Fn + B == Windows + Pause (open System properties).

You can execute the command:

dir /s C:\

and test the Pause and Break combination keys while dir lists all files in drive C.

reference

查看更多
乱世女痞
7楼-- · 2020-06-30 05:54

Ctrl + Fn + B works for Excel 365 (Office 365) on my Dell Latitude 5480 (no Break key).

查看更多
登录 后发表回答