How to interrupt a macro that is stuck in an InputBox loop?

Anonymous
2022-10-29T04:16:40+00:00

I have a macro that I use to tally some numbers. It puts up an InputBox, checks the input, loops if the input is invalid. I made the mistake of putting an IsNumeric call immediately after the InputBox. This means that clicking the Cancel button, which I was using to end the run, is now an error. The result is that it loops forever.

Here's a snippet of the code.

I have tried everything I can think of or can find online to interrupt this macro. This is on a Surface Book 1, which has no Break or Pause key.

These include:

  • Esc. This is treated jnust like Cancel or Enter.
  • Esc several times fast. Same result.
  • Ctrl+Esc
  • Win + Esc. I think this is also treated like Cancel.
  • Win+r (Break?). Rgis bring up the Run window.
  • Ctrl+Fn+B. Does nothing.
  • Ctrl+Fn+C. Does nothing.
  • Ctrl+Atl+Del. I can use this to close the worlbook, but then I lose unsaved changes, both in the workbook and the macro code.

The only thing that works is to force the workbook to close by clicking the "X" on its icon in the list of open workbooks or force the PC to restart. The problem with these solutions is that I lose any edits that I might have made since it was last saved.

There has to be a way to interrupt (close or enter debug) a macro like this.

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2022-10-29T06:53:32+00:00

    Does your keyboard have a Pause/Break key?

    If so, try pressing Ctrl+Pause/Break.

    If not, bring up the On-Screen Keyboard (click the Start button and search for it).

    Activate Excel or the Visual Basic Editor, then switch back to the On-Screen Keyboard.

    Click on Ctrl, then click on Pause.

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2022-10-29T07:22:01+00:00

    Does your keyboard have a Pause/Break key?

    If so, try pressing Ctrl+Pause/Break.

    If not, bring up the On-Screen Keyboard (click the Start button and search for it).

    Activate Excel or the Visual Basic Editor, then switch back to the On-Screen Keyboard.

    Click on Ctrl, then click on Pause.

    Yeah, I should have mentioned that. This stupid keyboard has no Pause or Break keys. I did bring up the On-Screen keyboard, which has a Pause key. But none of Pause, Ctrl+Pause, Win+Pause, and as many other combinations as I could think of worked. Pause did make a soft clicking, but it did not pause the macro.

    I ended up rebooting the PC and fixing the macro bug. But I would like to know how to interrupt a macro like that as I will probably do it again sometime. 😣

    Thanks

    3 people found this answer helpful.
    0 comments No comments