VBA & Macro Problems

How to Fix an Excel Macro Not Running from a Worksheet Module

Adam DavisAdam Davis Oct 29, 2026 873 views

Question details

The user is unable to run an automated VBA macro from a worksheet module due to naming conflicts or improperly structured event procedures.

How to Fix an Excel Macro That Will Not Run from a Worksheet Module
Product
Excel
Device & OS
not provided
Scenario
Writing and executing VBA macros intended to run automatically upon specific worksheet actions, such as changing a cell selection.
Observed behavior
The custom macro or event procedure fails to execute automatically, typically caused by duplicate event names or placing standard macros in the worksheet module.
Before you start

Ensure your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that macros are enabled in your Trust Center settings before testing VBA code.

Solution 1Recommended

Combine Duplicate Event Procedures

Excel allows only one instance of a specific event procedure (like Worksheet_SelectionChange) per worksheet module. You must merge multiple actions into one sub.

When you have multiple tasks that need to trigger on the same worksheet event, you cannot create separate procedures with the same name. Instead, all the code must be consolidated into a single event block.

1
Open the VBA Editor

Press ALT + F11 to open the Visual Basic for Applications (VBA) Editor and locate your specific Worksheet module in the Project Explorer.

2
Locate Duplicate Procedures

Search the code window for duplicate event procedures, such as multiple 'Private Sub Worksheet_SelectionChange' blocks.

3
Merge the Code

Copy the execution code from the duplicate blocks and paste them sequentially inside a single 'Worksheet_SelectionChange' procedure.

4
Delete Extra Blocks

Delete the extra, now-empty event procedure blocks to resolve the naming conflict and allow the macro to run.

Combine Duplicate Event Procedures
Check Code Placement: Make sure your event code is placed in the specific Worksheet object (e.g., Sheet1), not in a standard module like Module1.
Efficient Macro Editing in WPS

Manage and Run VBA Macros Seamlessly in WPS Spreadsheet

WPS Office provides robust VBA support, allowing you to easily write, edit, and execute macros just like in Microsoft Excel. You can organize worksheet events and standard modules in its intuitive VBA Editor.

  1. 1. Open your macro file: Launch WPS Spreadsheet and open your .xlsm workbook.
  2. 2. Access the VBA Editor: Go to the 'Developer' tab and click on 'Visual Basic' or press ALT + F11 to open the VBA editor.
  3. 3. Edit Worksheet Modules: Double-click the desired sheet in the Project window and consolidate your Worksheet_SelectionChange events.
  4. 4. Run your Macro: Save your changes and interact with the worksheet to trigger the combined event procedure.
Fully compatible with Microsoft Excel (.xlsm) macro-enabled formats.Built-in VBA Editor for seamless script management and debugging.Lightweight software that loads large macro files quickly.Supports standard worksheet events like Worksheet_SelectionChange.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my Worksheet_SelectionChange macro not triggering automatically?

This usually happens if macros are disabled in your security settings, if the code is placed in a standard module instead of the specific worksheet module, or if there is a syntax error preventing compilation.

Can I have multiple worksheet events in the same module?

Yes, you can have different types of events (e.g., Worksheet_SelectionChange and Worksheet_Change) in the same module. However, you cannot have two procedures with the exact same name for the same event type.

How do I call a macro from a standard module inside a worksheet event?

You can trigger a macro stored in a standard module by simply typing the name of the macro or using the 'Call' keyword inside your worksheet event procedure, like 'Call MyCustomMacro'.