How to Open Macros in Excel and View or Run Them

VBA & macros · Updated November 21, 2026

To open a macro in Excel for Microsoft 365 on Windows, open the workbook that contains it, then choose Developer > Macros, select the macro, and click Edit to view its VBA code or Run to execute it. If the Developer tab is missing, use Alt+F11 to open the Visual Basic Editor, or enable the tab in Excel Options. Only run macros from sources you trust: macros can change workbook data and may carry security risks.

“Open a macro” can mean finding its code, running it, or opening the workbook that contains it. The steps below cover all three. The Windows instructions apply to Excel for Microsoft 365; Mac and Excel for the web differences are noted where they matter.

What You’ll Need

  • A desktop version of Excel and the workbook containing the macro. Macro code is commonly stored in an Excel Macro-Enabled Workbook (.xlsm) or Excel Binary Workbook (.xlsb). An ordinary .xlsx file cannot store VBA macros.
  • Permission to access the workbook and, if needed, its VBA project. A password-protected VBA project may let you run a macro but prevent you from viewing its code.
  • A trusted source for the file. Do not enable macros simply because Excel displays a security warning; confirm that the file and its sender are legitimate first.

If you only have Excel for the web, you can open and edit many workbook contents, but you cannot run, create, or edit VBA macros there. Open the file in the desktop application instead.

Step-by-Step

  1. Open the workbook that contains the macro. In Excel, choose File > Open and browse to the file, or open it from its folder. Check the file extension: .xlsm and .xlsb can contain VBA, while .xlsx cannot. If the file came from email, a download, or a shared location, verify its source before proceeding. Excel may open the file in Protected View; if you trust the file, use the yellow message bar’s Enable Editing option before trying to access its macros. Do not treat that step as permission to enable macros automatically.
  2. Decide whether you need to view or run the macro. Viewing means opening the VBA code in the Visual Basic Editor. Running means telling Excel to execute the macro. If you are uncertain what a macro does, choose Edit or inspect the code first rather than clicking Run. A macro can alter cells, delete sheets, change files, or perform other actions that are difficult to reverse.
  3. Show the Developer tab if it is not already visible. On Windows, select File > Options > Customize Ribbon. In the Main Tabs list on the right, tick Developer, then click OK. The Developer tab should now appear on the ribbon. This is a display setting; it does not enable macros or make an unsafe workbook safe.
  4. Open the macro list. Select Developer > Macros. In the Macro dialog, review the list and the Macros in setting. Choose This Workbook to focus on the current workbook, or select another available workbook if the macro is stored elsewhere. The list may include macros from an open workbook or from the Personal Macro Workbook, if one is available.
  5. Run a macro you trust. In the Macro dialog, select its name and click Run. You can also select a macro and click Step Into to start stepping through its code in the Visual Basic Editor, which is useful for inspection and debugging. Some macros expect a particular sheet, selection, or input; read any instructions supplied with the workbook before running one. Save a backup copy first if the workbook contains important data.
  6. Open the macro’s VBA code. In Developer > Macros, select the macro and click Edit. Excel opens the Visual Basic Editor and usually highlights the procedure. You can also open the editor directly with Alt+F11. In the editor, use View > Project Explorer if the project list is not visible. Expand the project for your workbook, then look under Modules for standard macro code. A macro may instead be in a worksheet object, the ThisWorkbook object, or another project location.
  7. Find the right procedure in the editor. In Project Explorer, click a module to display its code. A procedure that can usually be run from the Macro dialog is a public Sub without required arguments; it often begins with a line such as Sub UpdateReport(). Use the procedure dropdowns above the code pane or search the project to locate a particular name. If the editor opens but shows an empty pane, confirm that you selected the correct workbook project and expanded its modules.
  8. Close the editor without losing track of the workbook. Return to Excel by closing the Visual Basic Editor window or pressing Alt+Q on Windows. If you changed code, save the workbook in a macro-capable format such as .xlsm when prompted. Saving a macro workbook as .xlsx removes its VBA project; Excel normally warns you before discarding that content. If you only inspected the code and made no changes, you can close the editor without editing the workbook.
  9. Use the Mac route when working on a Mac. Open the workbook in desktop Excel for Mac, then use the Developer tab’s Macros command to view the macro list. If Developer is hidden, enable it in Excel’s ribbon or toolbar customization settings; the exact labels can vary slightly by Mac release. Option+F11 opens the Visual Basic Editor on many Mac keyboards, though you may need to hold Fn as well. You can also open the editor from the Developer tab. Excel for Mac supports many VBA macros, but Windows-specific code, controls, or file paths may not work the same way.

On Windows, Alt+F8 opens the Macro dialog directly, while Alt+F11 opens the Visual Basic Editor. On Mac, Option+F8 is commonly used for the macro dialog and Option+F11 for the editor, but keyboard settings and function-key behavior can differ. Use the Developer ribbon commands if a shortcut is intercepted by your keyboard or operating system.

Common Mistakes

  • Looking for a macro inside an .xlsx file. The .xlsx format does not preserve VBA macros. Ask for the original .xlsm or .xlsb file, or check whether the macro is stored in another open workbook or in the Personal Macro Workbook.
  • Confusing the editor with the macro list. Alt+F11 opens the VBA editor; it does not run a macro. Alt+F8 opens the macro list, where you can choose Run or Edit.
  • Enabling every macro to make a warning disappear. Security prompts are there for a reason. Enabling content from an unknown file can expose your computer or data to harmful code. Verify the sender and the file through a separate trusted channel before changing security settings.
  • Saving a macro workbook in the wrong format. If Excel asks whether to keep using a macro-free format, choose a macro-enabled format if you need to retain VBA. Do not rename the file extension manually; use File > Save As and choose the appropriate file type.
  • Assuming every listed macro belongs to the current workbook. The Macro dialog can show items from other open workbooks or the Personal Macro Workbook. Check the Macros in setting and the workbook name before you run anything.
  • Expecting Ctrl+Z to undo a macro. Excel’s Undo history is generally cleared when a VBA macro runs. Keep a backup or use Save As to create a working copy before running code that changes data.

Tips

  • Read the macro’s description or accompanying documentation before running it. If you have access to the code, look for actions such as deleting sheets, clearing ranges, saving files, or opening external files.
  • Use a copy of the workbook for your first run, especially if the macro performs bulk updates. Confirm the results before replacing the original file.
  • Keep the file extension visible in File Explorer if you regularly work with macro files. In Windows File Explorer, choose View > Show > File name extensions so you can distinguish .xlsm from .xlsx.
  • If a macro is part of a routine task, you can assign it a button after confirming it is safe. On Windows, use Developer > Insert and select a Form Control button, then choose the macro when prompted. Avoid adding buttons to a shared workbook until you understand the macro’s effects.
  • For code inspection, make a note of the project name and module name. That helps you return to the same place later, particularly when several workbooks are open.
  • When sharing a workbook, tell recipients that it contains macros and explain what they do. A clear source and purpose make it easier for others to decide whether to enable them.

Troubleshooting

The Developer tab or Macros command is missing: On Windows, enable Developer through File > Options > Customize Ribbon. If the ribbon is simplified or narrow, some commands may be collapsed; widen the Excel window or check the overflow menu. On Mac, show the Developer tab through ribbon customization. If you are using Excel for the web, open the workbook in desktop Excel because VBA commands are not available in the web app.

The macro list is empty: Confirm that the correct workbook is open and that Macros in is set to the current workbook or the location where the macro is stored. Check that the file is .xlsm or .xlsb, not a copy saved as .xlsx. Also check whether the VBA project is in another open workbook or the Personal Macro Workbook. If you have only a read-only or preview copy, reopen the original file in desktop Excel.

Excel blocks the macro: Do not lower security settings for an unverified file. If you trust the source, follow your organization’s approved process or review the security notification and file properties. Your organization may manage macro settings, in which case the setting can be unavailable and an administrator may need to help. Files downloaded from the internet can receive extra security restrictions; only remove a block when you have independently confirmed the file is safe and your policy permits it.

Edit is unavailable or the code is hidden: The workbook may not contain a selectable VBA procedure, or its VBA project may be locked with a password. A locked project cannot be inspected without the authorized password. Ask the file owner for access or documentation rather than trying to bypass the protection.

The macro runs but gives an error: It may rely on a particular sheet name, cell selection, workbook layout, add-in, file location, or Windows-only feature. Read the error message, check the macro’s instructions, and confirm that required files and sheets are present. If you are debugging code, use the editor’s highlighted line and test on a copy. Mac users should ask whether the code uses Windows-only components or paths.

The workbook no longer contains its macro: Check whether it was saved as .xlsx after editing. If so, close without further saving and recover the original .xlsm/.xlsb copy from a backup, version history, or the sender. Once VBA has been discarded and the file saved, changing the extension back does not restore the macro.

Frequently Asked Questions

How do I open the VBA editor in Excel?
On Windows, press Alt+F11 or choose Developer > Visual Basic. On Mac, use Developer > Visual Basic or try Option+F11; some keyboards require Fn as well.

How do I run a macro without opening its code?
Choose Developer > Macros, select a macro, and click Run. Alt+F8 opens the dialog on Windows. Run only macros from sources you trust.

Can I open a macro in an .xlsx workbook?
An .xlsx file cannot store VBA macros. Look for the original .xlsm or .xlsb workbook, or check whether the macro is stored in a different open workbook or the Personal Macro Workbook.

Can I view or run VBA macros in Excel for the web?
No. Excel for the web can open many macro-enabled workbooks, but it does not run or edit VBA. Choose Open in Desktop App to use the Windows or Mac desktop version.

Why can I see a macro but not edit it?
The VBA project may be password-protected, or the macro may be stored in a location you cannot edit. Ask the workbook owner for the password or an accessible copy; do not try to bypass the protection.

Can I undo a macro with Ctrl+Z?
Usually not. Running VBA generally clears Excel’s Undo history. Save a separate copy before running a macro that may change important data.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.