How to Run a Macro in Excel: 4 Easy Methods (2025 Guide)
Quick Answer: To run a macro in Excel, press Alt+F8 to open the Macros dialog, select your macro, and click Run. For faster access, assign keyboard shortcuts or buttons to your frequently-used macros.
Why Run Macros in Excel?
Running macros is how you execute the automated tasks you've created or recorded. Once you know how to run macros efficiently, you can save hours of manual work with just a click or keystroke.
Common Reasons to Run Macros:
- Automate Repetitive Tasks: Format reports, clean data, generate summaries
- Process Large Datasets: Run calculations or transformations on thousands of rows
- Create Interactive Dashboards: Update charts and data with button clicks
- Standardize Workflows: Ensure tasks are completed the same way every time
Before You Run a Macro:
- ✓Make sure macros are enabled in your Excel settings
- ✓Save your work before running a new or untested macro
- ✓Test macros on a copy of your data first
- ✓Know what the macro does before running it
Method 1: Run Macro from Macros Dialog (Easiest)
The Macros dialog is the most straightforward way to run any macro in your workbook. This method works for all macros and doesn't require any setup.
Step-by-Step Instructions:
- 1
Open the Macros Dialog
Press Alt + F8 on your keyboard
Or: Developer tab → Macros button
- 2
Select Your Macro
Click on the macro name in the list
Tip: Macros are listed alphabetically
- 3
Click "Run"
The macro will execute immediately
Other Options in the Macros Dialog:
Step Into
Opens the VBA Editor and runs the macro line by line (for debugging)
Edit
Opens the VBA Editor to view or modify the macro code
Delete
Permanently removes the macro from your workbook
Options
Assign a keyboard shortcut or add a description to the macro
When to Use This Method:
- ✓Running macros occasionally (not frequently)
- ✓Testing a new macro for the first time
- ✓When you don't remember the keyboard shortcut
- ✓Accessing macro options (edit, delete, assign shortcut)
Method 2: Run Macro with Keyboard Shortcut (Fastest)
Keyboard shortcuts are the fastest way to run macros you use frequently. Once assigned, you can execute your macro instantly without opening any dialogs.
How to Assign a Keyboard Shortcut:
- 1
Open Macros Dialog
Press Alt + F8
- 2
Select Your Macro
Click on the macro name
- 3
Click "Options"
Opens the Macro Options dialog
- 4
Assign Shortcut Key
Type a letter in the "Shortcut key" box
Example: Type "M" to create Ctrl+Shift+M
- 5
Click OK
Your shortcut is now active!
Keyboard Shortcut Format:
Lowercase Letter (a-z):
Creates Ctrl + Shift + [Letter]
Example: "m" = Ctrl+Shift+M
Uppercase Letter (A-Z):
Creates Ctrl + [Letter]
Example: "M" = Ctrl+M (may override Excel shortcuts)
⚠️ Avoid These Shortcuts:
Some keyboard shortcuts are already used by Excel. Avoid overriding these common ones:
Recommendation: Use Ctrl+Shift combinations (lowercase letters) to avoid conflicts.
Best Practices for Shortcuts:
- ✓
Use Memorable Letters
Example: "F" for Format, "R" for Report, "C" for Calculate
- ✓
Document Your Shortcuts
Keep a list of which shortcuts run which macros
- ✓
Test Before Assigning
Make sure the shortcut doesn't conflict with Excel features you use
- ✓
Reserve for Frequent Macros
Only assign shortcuts to macros you run daily or multiple times per day
Running Macro with Shortcut:
Once assigned, simply press your keyboard shortcut anywhere in Excel to run the macro instantly. No need to open dialogs or click buttons!
Example: If you assigned Ctrl+Shift+M to your "MonthlyReport" macro, just press those three keys together to generate your report.
Method 3: Run Macro with a Button (Most User-Friendly)
Buttons make macros accessible to anyone using your workbook, even if they don't know keyboard shortcuts or how to open the Macros dialog. Perfect for creating interactive dashboards and reports.
How to Create a Button to Run Your Macro:
- 1
Go to Developer Tab
Click the Developer tab in Excel ribbon
- 2
Insert Button
Click Insert → Button (Form Control)
- 3
Draw the Button
Click and drag on your worksheet to create the button
- 4
Assign Macro
Select your macro from the list and click OK
- 5
Customize Button Text
Right-click → Edit Text → Type a descriptive label
- 6
Click to Run
Click anywhere outside the button, then click the button to run your macro!
Button Customization Tips:
Format the Button
Right-click → Format Control to change colors, size, and appearance
Resize the Button
Click the button, then drag the corner handles to resize
Move the Button
Right-click → drag to move it to a new location
Delete the Button
Right-click → Cut (or press Delete key)
Alternative: Use Shapes as Buttons
For more design flexibility, you can use shapes instead of form control buttons:
- 1. Insert → Shapes → Choose any shape
- 2. Draw the shape on your worksheet
- 3. Right-click the shape → Assign Macro
- 4. Select your macro and click OK
- 5. Format the shape with colors, effects, and text
Benefit: Shapes offer more design options like gradients, shadows, and 3D effects.
When to Use Buttons:
- ✓Creating dashboards for non-technical users
- ✓Making macros visible and discoverable
- ✓Building interactive reports with multiple actions
- ✓When sharing workbooks with others
Method 4: Auto-Run Macros (Advanced)
Auto-run macros execute automatically when specific events occur, like opening a workbook, activating a worksheet, or changing a cell value. This is perfect for automation that should happen without user intervention.
⚠️ Security Note
Auto-run macros can be a security risk. Only use them in workbooks you trust, and be cautious when sharing files with auto-run macros. Recipients may disable macros for security reasons.
Option 1: Run Macro When Workbook Opens
Use the Workbook_Open event to run a macro automatically when the file opens.
' In VBA Editor: Double-click "ThisWorkbook" in Project Explorer
' Paste this code:
Private Sub Workbook_Open()
' Your code here runs when workbook opens
MsgBox "Welcome! This macro runs automatically."
' Example: Run another macro
Call YourMacroName
End SubWhen to use: Initialize settings, load data, display welcome messages, or run setup tasks.
Option 2: Run Macro When Worksheet Activates
Use the Worksheet_Activate event to run a macro when a specific sheet is selected.
' In VBA Editor: Double-click the sheet name in Project Explorer
' Paste this code:
Private Sub Worksheet_Activate()
' Your code here runs when this sheet is activated
Range("A1").Select
MsgBox "You are now on the " & Me.Name & " sheet"
End SubWhen to use: Refresh data, update charts, or highlight specific cells when users navigate to a sheet.
Option 3: Run Macro When Cell Value Changes
Use the Worksheet_Change event to run a macro when any cell value changes.
' In VBA Editor: Double-click the sheet name in Project Explorer
' Paste this code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Run only if cell A1 changes
If Target.Address = "$A$1" Then
MsgBox "Cell A1 was changed to: " & Target.Value
' Your code here
End If
End SubWhen to use: Validate input, trigger calculations, or update related cells automatically.
Option 4: Run Macro Before Workbook Closes
Use the Workbook_BeforeClose event to run cleanup tasks before closing.
' In VBA Editor: Double-click "ThisWorkbook" in Project Explorer
' Paste this code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Your code here runs before workbook closes
Dim response As VbMsgBoxResult
response = MsgBox("Save backup before closing?", vbYesNo)
If response = vbYes Then
Call CreateBackup
End If
End SubWhen to use: Save backups, export data, or prompt users before closing.
Common Auto-Run Events:
• Workbook_Open: When workbook opens
• Workbook_BeforeClose: Before workbook closes
• Workbook_BeforeSave: Before workbook saves
• Worksheet_Activate: When sheet is selected
• Worksheet_Change: When cell value changes
• Worksheet_SelectionChange: When selection changes
Best Practices for Auto-Run Macros:
- ✓Keep auto-run code simple and fast
- ✓Add error handling to prevent crashes
- ✓Document auto-run behavior for other users
- ✓Provide a way to disable auto-run if needed
- ✓Test thoroughly before sharing with others
Troubleshooting: Macro Won't Run?
Problem: Macros Are Disabled
Symptoms: Yellow security warning bar appears, or macros don't appear in the Macros dialog.
Solution:
- 1. Click "Enable Content" on the yellow warning bar
- 2. Or go to File → Options → Trust Center → Trust Center Settings → Macro Settings
- 3. Select "Disable all macros with notification"
- 4. Click OK and reopen the file
Problem: Macro Not in List
Symptoms: Your macro doesn't appear in the Macros dialog (Alt+F8).
Possible Causes & Solutions:
- • Wrong workbook: Make sure the correct workbook is selected in the "Macros in" dropdown
- • Private macro: Macros declared as "Private Sub" don't appear in the list
- • Function instead of Sub: Only Sub procedures appear in the Macros dialog, not Functions
- • Macro was deleted: Check the VBA Editor (Alt+F11) to verify the macro exists
Problem: Error Message When Running
Symptoms: Macro starts but shows an error message.
Solutions:
- • Debug the code: Press Alt+F11, click Debug → Compile VBAProject to find errors
- • Check references: Make sure all cell references and sheet names are correct
- • Missing objects: Verify that sheets, ranges, or files the macro references still exist
- • Permissions: Ensure you have permission to modify the workbook
Problem: Keyboard Shortcut Doesn't Work
Symptoms: Pressing the shortcut does nothing or runs a different command.
Solutions:
- • Check assignment: Open Macros dialog (Alt+F8) → Options to verify the shortcut
- • Conflict with Excel: The shortcut may override an Excel command (try a different key)
- • Caps Lock: Uppercase vs lowercase letters create different shortcuts
- • Reassign: Delete and reassign the shortcut
Problem: Button Doesn't Run Macro
Symptoms: Clicking the button does nothing.
Solutions:
- • Check assignment: Right-click button → Assign Macro to verify it's linked
- • Macro was renamed: Reassign the button to the correct macro
- • Edit mode: Make sure you're not in button edit mode (click outside button first)
- • Protected sheet: Unprotect the worksheet to allow button clicks
Problem: Macro Runs But Does Nothing
Symptoms: Macro executes without errors but doesn't produce expected results.
Solutions:
- • Wrong sheet active: The macro may be working on a different sheet than you expect
- • Check the code: Review the VBA code to ensure it's doing what you think
- • Step through: Use F8 in VBA Editor to run the macro line by line
- • Add MsgBox: Insert MsgBox statements to see what values the macro is using
How to Stop a Running Macro:
If a macro is stuck in an infinite loop or taking too long:
- • Press Esc key
- • Press Ctrl + Break
- • If Excel is frozen, use Task Manager to close Excel (Ctrl+Alt+Delete)
Frequently Asked Questions
What's the fastest way to run a macro in Excel?
The fastest way is using a keyboard shortcut. When creating or editing a macro, assign it a shortcut like Ctrl+Shift+M. Then you can run it instantly by pressing that key combination.
How do I run a macro from the Macros dialog?
Press Alt+F8 to open the Macros dialog, select your macro from the list, and click Run. This is the most straightforward method for running any macro in your workbook.
Can I run a macro by clicking a button?
Yes, you can assign macros to buttons. Go to Developer tab → Insert → Button (Form Control), draw the button, assign your macro, and click the button to run it anytime.
How do I make a macro run automatically when I open Excel?
Create a macro named "Auto_Open" or use the Workbook_Open event in the ThisWorkbook module. The macro will run automatically every time you open the workbook.
Why won't my macro run?
Common reasons: macros are disabled (enable them in Trust Center), the file isn't saved as .xlsm format, there's an error in the VBA code, or the macro name has changed. Check each of these issues.
Can I run a macro from another workbook?
Yes, if the macro is in the Personal Macro Workbook or if you reference the other workbook in your code. You can also copy the macro to your current workbook.
How do I stop a macro that's running?
Press Esc or Ctrl+Break to stop a running macro. If it's stuck in an infinite loop, you may need to force-quit Excel and restart.
Can I run multiple macros at once?
Yes, create a master macro that calls other macros using "Call MacroName" or "Application.Run 'MacroName'". This lets you run multiple macros in sequence with one click.