logo
search
VBA & Macro Problems

How to Fix Excel Macro Not Running from Shortcut or Button

Phi Hung VoPhi Hung Vo Oct 20, 2026 868 views

Question details

The user needs to fix a recorded Excel macro that executes correctly from the Developer tab but fails to run when using an assigned keyboard shortcut or form button.

How to Fix an Excel Macro Not Running from a Shortcut or Button
Product
Microsoft Excel
Device & OS
not provided
Scenario
Attempting to run a newly recorded macro using a custom keyboard shortcut or a shape/button placed on the worksheet.
Observed behavior
The macro fails to execute or produces incorrect results when triggered via shortcut or button, despite running flawlessly when executed manually from the Developer tab.
Before you start

Before troubleshooting, verify that your workbook is saved as a Macro-Enabled Workbook (.xlsm) and that you have clicked 'Enable Content' in the security warning bar at the top of the worksheet.

Solution 1Recommended

Reassign the Macro to the Shortcut or Button

Re-establishing the connection between your trigger (button or shortcut) and the macro ensures it is calling the correct script.

1
Reassign to a Button

Right-click the button or shape on your worksheet, select 'Assign Macro' from the context menu, choose your newly recorded macro from the list, and click 'OK'.

2
Open Macro Options

To check keyboard shortcuts, navigate to the Developer tab on the ribbon and click on the 'Macros' button to open the Macro dialog box.

3
Set Keyboard Shortcut

Select your target macro from the list and click 'Options'. In the 'Macro Options' dialog, enter your desired shortcut key (e.g., Ctrl+Shift+M) and click 'OK'.

Reassign the Macro to the Shortcut or Button
Macro Scope: Ensure the 'Macros in' dropdown menu is set to 'This Workbook' so that the shortcut specifically targets the macro within your current file.
Manage Macros Easily in WPS Office

Run and Automate Macros Flawlessly with WPS Spreadsheet

WPS Office Spreadsheet provides excellent built-in compatibility for Microsoft Excel macros (VBA). You can easily record, edit, and assign macros to buttons or keyboard shortcuts to automate your daily tasks without facing execution errors.

  1. 1. Open Your File: Launch WPS Spreadsheet and open your macro-enabled workbook (.xlsm).
  2. 2. Access Developer Tools: Navigate to the 'Developer' tab on the ribbon and click 'Macros' to manage your recorded scripts.
  3. 3. Assign a Shortcut: Select a macro, click 'Options', and assign a personalized keyboard shortcut.
  4. 4. Create a Button: Go to the 'Insert' tab, insert a shape, right-click it, and select 'Assign Macro' to turn it into a clickable trigger.
Highly compatible with Microsoft Excel (.xlsm) macro files and VBA syntaxIntuitive Developer tab for seamless macro recording and code managementEasily assign customized scripts to shapes, buttons, and custom shortcutsFree, lightweight, and fast-loading office suite for everyday productivity
microsoft office alternative - wps office

Frequently Asked Questions

Why does my macro only work when I run it from the Developer tab?

This usually happens when the keyboard shortcut or form control button assigned to the macro gets disconnected, or was assigned to an older, deleted version of the macro. Reassigning the macro to your button or shortcut typically resolves this issue.

How do I make my recorded macro use relative references instead of fixed cells?

Before you start recording a macro in the Developer tab, click the 'Use Relative References' button. This ensures your macro actions are recorded relative to the currently active cell, rather than hardcoding exact cell addresses.

Can macro security settings disable my keyboard shortcuts?

Yes. If your macro security is set to 'Disable all macros without notification', macros cannot be triggered via shortcuts or buttons. Change your settings in the Trust Center to allow macro execution or to prompt you with a notification.

What should I look for in the VBA code if my recorded macro fails?

Check for absolute range commands like Range("A1:B5").Select. If the macro is meant to be dynamic, these should be replaced with relative VBA commands like ActiveCell, Selection, or Offset to interact appropriately with the user's current selection.