How to Stop an Excel VBA Macro Stuck in an InputBox Loop
Question details
The user needs to terminate an Excel VBA macro that is trapped in a continuous InputBox loop, particularly on a laptop device that lacks a physical Break key.

- Product
- Microsoft Excel
- Device & OS
- Windows
- Scenario
- Running a VBA script containing an InputBox where clicking Cancel triggers an error with IsNumeric, sending the script into an inescapable infinite loop.
- Observed behavior
- The InputBox repeatedly prompts the user on the screen. Clicking Cancel or closing the box fails to terminate the script, and the user cannot use the standard Ctrl+Break shortcut because the keyboard has no Pause/Break key.
Before attempting to forcefully interrupt the macro, check if you can save your work in any other open workbooks, as using task-killing methods as a last resort may lead to unsaved data loss.
Interrupt the Macro Using the Windows On-Screen Keyboard
This is the most effective method to simulate the Ctrl+Break shortcut when your physical laptop keyboard does not have a Pause/Break key.
The standard way to halt a running VBA macro is by pressing Ctrl + Pause/Break. For modern laptops missing this key, the built-in Windows On-Screen Keyboard provides a fully functional virtual alternative.
Click the Windows Start menu, type 'On-Screen Keyboard' into the search bar, and launch the application.
Click on the Excel or Visual Basic Editor window where the InputBox loop is actively running so that it is in the foreground.
On the On-Screen Keyboard, click the 'Ctrl' key once to highlight it, and then click the 'Pause' key.
A VBA interruption dialog box will appear. Click 'End' to completely stop the macro from running.

Modify the VBA Code to Properly Handle InputBox Cancel
Prevent the infinite loop from happening in the first place by properly evaluating the InputBox output before applying the IsNumeric function.
Force Quit the Application via Task Manager
Use Task Manager as an absolute last resort if the macro completely freezes the application and the On-Screen Keyboard interruption fails.
Write and Debug VBA Macros Safely in WPS Spreadsheet
WPS Spreadsheet offers a robust, built-in Visual Basic Editor that perfectly handles VBA scripts. Its advanced debugging tools make it easier to catch logical errors like infinite InputBox loops before they crash your workspace.
- 1. Access the Developer Tab: Open WPS Spreadsheet and navigate to the 'Developer' tab on the top ribbon.
- 2. Open the VBA Editor: Click 'Visual Basic Editor' to access your scripts and macros.
- 3. Debug Your Code: Use the 'Step Into' feature (F8) to test your InputBox loops safely and monitor variable changes in real time.
- 4. Implement Proper Validation: Edit the VBA code to safely handle empty string returns when users hit the Cancel button.

Frequently Asked Questions
Why does clicking Cancel on my VBA InputBox cause an infinite loop?
When you click Cancel on a VBA InputBox, it returns an empty string (""). If your code evaluates this result using the IsNumeric function before checking if it's empty, the evaluation fails. Depending on your loop structure (like a Do While loop), this can cause the code to continuously loop and repeatedly show the InputBox.
Is there an alternative shortcut to Ctrl+Break on modern laptops?
Yes. Since many modern laptops omit the physical Pause/Break key, manufacturers map this function to secondary keybindings. Common combinations include Fn + B, Fn + Esc, or Ctrl + Fn + Right Shift. Check your laptop manufacturer's official documentation for the specific shortcut.
Will stopping a macro with Ctrl+Break cause me to lose my spreadsheet data?
No, using the Ctrl+Break (or Ctrl+Pause) shortcut simply halts the execution of the running VBA script. It does not close the spreadsheet application, so your unsaved cell data remains safe. However, if you are forced to use Task Manager to end the application process, unsaved data will be lost.




