Executing a macro in Excel runs a recorded or written sequence of actions—such as formatting, data entry, or calculations—to automate repetitive tasks. You need a macro already created (recorded or VBA-coded) and Excel with macro support enabled (e.g., .xlsm workbook format or macro-enabled template). This guide covers running macros in modern Excel versions (2016, 2019, 2021, Microsoft 365) on Windows and macOS.

What You'll Need

  • A macro saved in the current workbook, Personal Macro Workbook, or an add-in
  • Excel file opened in macro-enabled format (.xlsm, .xlsb, or .xls with macros enabled)
  • Macros enabled in Excel Trust Center settings
  • Basic familiarity with Excel ribbon tabs (View, Developer)

Step-by-Step

  1. Open your Excel file containing the macro. If the macro was recorded or written for a specific workbook, ensure that file is open. If it’s stored in your Personal Macro Workbook (PERSONAL.XLSB), you can run it from any workbook.
  2. Enable the Developer tab if it’s not visible. Go to File > Options > Customize Ribbon. In the right-hand list under “Main Tabs,” check the box next to Developer, then click OK. The Developer tab now appears in the ribbon.
  3. Open the macro list by clicking the Macros button in the Developer tab (far left). Alternatively, press Alt + F8 on Windows or Fn + F8 on Mac (or Control + F8 if Fn lock is on). This opens the Macro dialog box.
  4. Select the macro to run from the list. If your macro is in PERSONAL.XLSB or another workbook, use the “Macros in” dropdown to choose the correct workbook. Highlight the macro name (e.g., “FormatSalesData” or “CopyPasteSpecial”).
  5. Run the macro. Click the Run button. On macOS, the button says “Run”; on Windows, it says “Run” or appears as a green triangle. The macro executes immediately—watch the status bar or screen for activity.
  6. Confirm completion. Excel returns to the previous view once done. Check the worksheet(s) to verify the expected changes occurred (e.g., new formatting, updated values). If the macro uses message boxes, click OK to dismiss them before proceeding.

Common Mistakes

  • Using .xlsx instead of .xlsm: Excel disables macros in .xlsx files. Save the file as Excel Macro-Enabled Workbook (.xlsm) before recording or saving macros.
  • Developer tab missing: If you can’t see the Developer tab, follow Step 2 to enable it—don’t skip this; it’s required for many macro management actions.
  • Macro security blocking execution: If Excel shows a security warning or the Run button is grayed out, macro execution may be disabled (see Troubleshooting).
  • Running from the wrong workbook: If the macro isn’t listed, ensure the correct workbook is selected in the “Macros in” dropdown. Macros in PERSONAL.XLSB appear only if that hidden workbook is loaded.
  • Assuming macros work across versions: Some VBA functions behave differently in Excel for Mac vs. Windows (e.g., Windows API calls). Test macros on the target platform.

Tips

  • Name macros clearly: Use descriptive names like “UpdateQuarterlyReport” instead of “Macro1” to avoid confusion and simplify future runs.
  • Assign a shortcut key: In the Macro dialog, click Options after selecting a macro, then assign a letter (e.g., “R” for Ctrl+Shift+R). This lets you run the macro instantly with a key combo.
  • Use the Quick Access Toolbar: Add the Macros button to the QAT (File > Options > Quick Access Toolbar > Choose Commands From: All Commands > Macros > Add). This provides one-click access without opening the Developer tab.
  • Test in a copy first: Run new or unfamiliar macros on a duplicate worksheet to avoid accidental data loss.
  • Pause or debug with F8: In the VBA editor (Alt+F11), press F8 to step through macro code line-by-line. This helps verify logic before full execution.
  • Check macro location: To see where a macro is stored, look at the “Project” pane in the VBA editor (Alt+F11). A macro in “VBAProject (Personal.xlsb)” is available globally; one in “VBAProject (MyReport.xlsx)” is file-specific.

Troubleshooting

If your macro doesn’t run, follow these steps in order:

  1. Restart Excel. Sometimes Excel holds temporary locks or memory issues. Close all Excel windows, reopen, and try again.
  2. Verify macro security settings. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Choose “Disable all macros with notification” (recommended) or “Enable all macros” (only for trusted files). Avoid “Disable all macros without notification”—it silently blocks execution.
  3. Check for macro warnings. When opening the file, Excel should display a security warning bar at the top. Click “Enable Content” if present. If the bar isn’t visible, macros may be disabled in the Trust Center.
  4. Confirm the macro exists in the active workbook. In the Macro dialog (Alt+F8), scroll the list. If it’s missing, the macro may be in PERSONAL.XLSB. To check, open PERSONAL.XLSB via File > Open > Personal Macro Workbook (if available), or unhide it in the VBA editor (View > Show > Unhide).
  5. Repair the VBA project. In the VBA editor (Alt+F11), go to Tools > References. Look for missing or broken references (marked “MISSING:”). Uncheck them, click OK, then re-add essential libraries (e.g., VBA, Excel, Office) if needed.
  6. Test in a new workbook. Create a blank .xlsm file, record a simple macro (e.g., highlight cell A1), and run it. If it works, the issue lies with the original file’s structure, VBA project, or code.
  7. Reset Excel settings. As a last resort, start Excel in Safe Mode (hold Ctrl while clicking Excel in Windows, or launch with Shift on Mac). In Safe Mode, macros run without add-ins interfering. If successful, disable add-ins (File > Options > Add-ins > Go) one by one to identify conflicts.

Frequently Asked Questions

Can I run a macro from the right-click menu?

Yes, but only after adding it to the Quick Access Toolbar or ribbon. Excel doesn’t support direct right-click macro assignment natively. Use the Developer tab’s Macros button or assign a shortcut key instead.

Why does my macro disappear after closing Excel?

It’s likely saved only in the current workbook, which you closed without saving. To keep macros permanent, save the file as .xlsm before closing. For universal access, store macros in PERSONAL.XLSB (record while PERSONAL.XLSB is the active workbook).

Do I need administrator rights to run macros?

No—regular user permissions suffice. However, organizational policies (e.g., in corporate environments) may disable macros via Group Policy, requiring IT approval to change Trust Center settings.

Can I run a macro automatically when opening a file?

Yes. Create a macro named Auto_Open (for older compatibility) or use the Workbook_Open event in the ThisWorkbook module of the VBA editor. Note: Users must still enable macros when opening the file for the event to trigger.

Is there a way to run a macro without opening the Developer tab?

Absolutely. Use the keyboard shortcut Alt+F8 (Windows) or Fn+F8/Control+F8 (Mac), or add the Macros button to the Quick Access Toolbar for one-click access. You can also assign a custom shortcut key (e.g., Ctrl+Shift+M) when creating or editing the macro options.

Why does Excel show a “macro disabled” message even after enabling content?

This usually happens if the file was downloaded from the internet and blocked by Windows’ zone identifier. Right-click the file > Properties > check “Unblock,” then reopen Excel and enable content again. On macOS, check “Open with Excel” from the Finder’s Get Info window if flagged.