VBA & Macro Problems

Fix Excel and Word VBA On Error Handler Not Working

Tauseeq MagsiTauseeq Magsi Nov 2, 2026 869 views

Question details

The VBA code halts execution when encountering an error instead of passing control to the designated On Error handler.

Fix Excel and Word VBA On Error Handler Not Working
Product
Excel and Word
Device & OS
not provided
Scenario
Running a VBA macro that contains On Error GoTo or On Error Resume Next statements for error handling.
Observed behavior
The Visual Basic Editor interrupts the macro and displays a run-time error dialog on the faulty line, completely bypassing the user's programmed error handling logic.
Before you start

Before altering your editor settings, create a brand-new blank document, add a simple macro with an 'On Error Resume Next' statement, and trigger a deliberate error (like dividing by zero). If it works perfectly in the new file, your original document's VBA project may be corrupted.

Solution 1Recommended

Adjust Visual Basic Editor Error Trapping Settings

The most common reason for bypassed error handlers is an incorrect global setting in the VBA editor that forces the compiler to break on every single error.

By default, the Visual Basic Editor is designed to pause execution on unhandled errors only. If this setting was accidentally changed to 'Break on All Errors', your custom error handlers will be ignored entirely.

1
Open the Visual Basic Editor

Open your affected Excel workbook or Word document and press Alt + F11 on your keyboard to launch the Visual Basic Editor (VBE).

2
Access VBE Options

In the top menu bar of the editor, click on 'Tools' and select 'Options' from the dropdown menu.

3
Modify Error Trapping

Navigate to the 'General' tab in the Options dialog box. Under the 'Error Trapping' section, change the selection from 'Break on All Errors' to 'Break on Unhandled Errors'.

4
Save and Test

Click 'OK' to save your settings. Run your macro again to verify that your On Error routines are now successfully capturing the errors.

Adjust Visual Basic Editor Error Trapping Settings
Setting Applied Globally: This setting applies to the VBA editor environment itself, meaning adjusting it once will fix the behavior across all your Excel and Word files.
Free Microsoft Office alternative

Experience Stable VBA and Macros with WPS Office

If Microsoft Office repair tools fail to resolve your persistent VBA environment issues, consider switching to WPS Office. It provides a highly stable, built-in macro editor designed to handle your complex automation tasks without missing a beat.

  1. 1. Download and Install: Visit the official WPS Office website to download the free installer and follow the quick setup wizard.
  2. 2. Open Your Macro File: Launch WPS Spreadsheet or Writer and open your existing .xlsm or .docm file directly.
  3. 3. Enable Macros and Run: Click 'Enable Macros' on the security prompt, press Alt + F11 to view your code, and run your automation tasks smoothly.
Free and lightweight alternative to Microsoft OfficeFully compatible with Microsoft Excel (.xlsm) and Word (.docm) macro-enabled formatsBuilt-in VBA environment that accurately respects your On Error handling logicFamiliar user interface requiring zero learning curve for macro developers
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VBA code ignore On Error Resume Next?

This almost always happens when the Visual Basic Editor's Error Trapping option is set to 'Break on All Errors'. Adjusting it to 'Break on Unhandled Errors' via Tools > Options > General will restore normal error handler functionality.

How do I know if my Excel workbook's VBA code is corrupted?

If you write a simple macro with an error handler in a brand-new, blank workbook and it works perfectly, but the exact same code fails in your current file, the original workbook's VBA project is likely corrupted.

Can third-party COM add-ins interfere with VBA execution?

Yes, incompatible third-party COM or Excel add-ins can disrupt the VBA compiler's state. You can diagnose this by launching Excel or Word in Safe Mode, or manually disabling add-ins one by one via File > Options > Add-ins.

Will repairing Microsoft Office fix my VBA editor settings?

Office repairs (both Quick and Online) typically fix corrupted program files and registry keys, but they may not reset user-configured preferences in the Visual Basic Editor like the Error Trapping state.