Excel Macro Recorder: View Its Code in the VBA Editor

VBA & macros · Updated November 11, 2026

Yes. In Excel for Microsoft 365 on Windows, choose Developer > Macros, select the recorded macro, and click Edit to open its VBA code in the Visual Basic Editor (VBE). You can also press Alt+F8, select the macro, and click Edit; the editor shows the instructions Excel recorded, which you can inspect or change.

What the Macro Recorder Saves

Excel’s Macro Recorder translates many actions you perform in a workbook into Visual Basic for Applications (VBA) statements. For example, selecting a cell, entering a value, applying a number format, and adjusting a column can result in code that selects ranges and changes their properties. The recorder is useful for learning basic VBA and automating repeated sequences without writing every instruction from scratch.

The saved result is code, not a replayable video or a list of plain-language steps. In the editor, you will usually find a procedure beginning with a line such as Sub followed by the macro name and ending with End Sub. Between those lines are the recorded operations. The exact statements depend on what you did, the workbook’s state, and whether relative references were enabled when you recorded.

Not every Excel action can be recorded, and recorded code may include extra selections or screen updates that a carefully written macro would not need. Viewing the code lets you see what Excel captured; it does not mean the recorder has produced a complete, general-purpose program.

Open a Recorded Macro in the Editor

On Windows, use either route below. Both open the macro list, from which you can select a macro and send it to the editor.

  1. Choose Developer > Macros.
  2. Alternatively, press Alt+F8 to open the Macro dialog.
  3. In the list, select the macro you want to inspect. Check the macro name and its workbook location if several entries are listed.
  4. Click Edit. Excel opens the VBE and displays the procedure’s location.

If the Developer tab is missing, go to File > Options > Customize Ribbon, select the Developer check box in the main-tab list, and choose OK. You do not need to enable the tab to use Alt+F8.

On Excel for Mac, use Tools > Macro > Macros, select the macro, and choose Edit. The VBE shortcut is commonly Option+F11; on some keyboards you may also need to hold Fn. The Developer tab can be enabled through Excel’s ribbon and toolbar customization settings if you prefer working from the ribbon. Menu wording can vary slightly by Mac Excel release.

Find the Macro After the Editor Opens

The VBE organizes code into projects, modules, and procedures. A project generally corresponds to an open workbook or to another VBA project available in that Excel session. In the Project Explorer pane, expand a project and then expand its Modules folder. Double-click a module to display its code. The selected macro is normally highlighted when you used the Edit button, but the module may contain several procedures.

If Project Explorer is not visible, press Ctrl+R in the Windows VBE or use View > Project Explorer. On Mac, use the corresponding View menu in the VBE. If you see a blank code area, check that the correct project and module are selected. You may also have opened a different workbook’s project from the one that contains the macro.

Macros can be stored in different places. A macro saved in This Workbook belongs to that workbook; a macro saved in the Personal Macro Workbook is usually stored in the hidden Personal.xlsb file and can be available when you open Excel; a macro saved in a New Workbook belongs to that separate workbook. If the macro is in Personal.xlsb, look for its project in Project Explorer rather than assuming it is part of the workbook currently on screen.

Read the Recorded VBA

Start at the procedure’s opening line and read downward. A recorded procedure commonly refers to workbook objects, worksheets, ranges, cells, and formatting properties. For instance, code that refers to a sheet by name is tied to that sheet name, while code that uses a range such as A1 may act on a different sheet if the active sheet changes. The editor displays the actual instructions; use them to determine what the macro will affect rather than relying only on its name.

Pay particular attention to selections and active objects. The recorder often writes steps that select a worksheet or cell before changing it. That can make the macro depend on which workbook, sheet, or cell is active when it runs. Absolute references usually point to a fixed location, while relative recording can make actions depend on the starting selection. Excel’s Developer > Use Relative References control determines whether relative references are used while recording; it is a recording setting, not a switch that changes existing code after the fact.

Recorded code may also contain repetitive statements or references to the current selection. That is normal. A recorded macro can be a useful starting point, but if you plan to reuse it on other sheets or workbooks, inspect assumptions such as worksheet names, selected ranges, and whether the data always begins in the same cell.

Inspecting Is Different from Editing or Running

Opening a procedure to view it does not run it. In the VBE, you can examine the statements without changing the workbook. To make a change, edit the code window, then save the workbook in a macro-enabled format such as .xlsm if it contains VBA. A standard .xlsx workbook cannot store VBA macros; saving a macro-containing workbook as .xlsx removes the VBA project, so heed Excel’s format warning.

To run a macro, return to Excel and use Developer > Macros or Alt+F8, select it, and choose Run. The VBE also has run controls, but running from the editor is not necessary just to inspect code. Avoid clicking Run or using the editor’s run command unless you intend to execute the procedure.

Macros can make changes that Excel cannot reverse with the normal Undo command. Before running an unfamiliar or edited macro, save a separate copy of the workbook. If a macro deletes data, changes many cells, or saves files, the copy provides a safer way to recover than relying on Ctrl+Z. For a macro you do not recognize, inspect its code and confirm its source before running it.

When the Macro Does Not Appear

If the Macro dialog does not list the procedure, first check the Macros in setting in that dialog. It may be showing only macros from the current workbook when the code is in Personal.xlsb, or vice versa. Also verify that the workbook containing the macro is open and that it was saved in a format that retains VBA.

  • The macro is in a different workbook: Open that workbook or choose the appropriate location in the Macro dialog.
  • The macro is in Personal.xlsb: Look for the Personal project in Project Explorer. The personal macro workbook is normally hidden in Excel’s worksheet area, but its VBA project can still be available in the editor.
  • The code is not in a standard module: Some procedures are stored in a worksheet or workbook object rather than under Modules. Expand the project and inspect its objects as well.
  • The file was saved as .xlsx: VBA may have been removed when the file was saved in a macro-free format. Check a backup or earlier macro-enabled copy.

A recorded macro might also be unavailable because macros are disabled or because the file came from an untrusted source. Do not lower security settings simply to see code. If you can open the VBE, code inspection is distinct from authorizing a macro to run; follow your organization’s security policy and only execute code from a source you trust.

Excel for the Web and Other Differences

Excel for the web does not provide the VBA editor or support recording, editing, or running VBA macros in the way desktop Excel does. You can open a macro-enabled workbook in the browser for supported workbook tasks, but to inspect its VBA code, open it in the Excel desktop app on Windows or Mac. The browser may preserve the workbook file without exposing the VBA project for editing.

Excel for Mac has a VBA editor and can work with many VBA macros, but some Windows-specific VBA features and external integrations may not behave the same on Mac. If your goal is simply to view a recorded procedure, the main workflow is still to open the macro list and choose Edit. If your goal is to run or adapt it across operating systems, check any platform-specific references in the code first.

Frequently Asked Questions

Can I view a macro without running it?
Yes. Select the macro and click Edit to open its code in the VBE. Opening the code for inspection does not execute the procedure.

Why does clicking Edit show a different macro or module?
The selected procedure may share a module with other macros, or the macro may belong to another open workbook. Check the procedure name and project in Project Explorer, and confirm the selected item in the Macro dialog.

Can I see a macro’s code in Excel for the web?
No. The browser version does not include the VBA editor. Open the file in desktop Excel for Windows or Mac to inspect the VBA project.

Can I edit a recorded macro and keep the changes?
Yes. Edit the procedure in the VBE and save the workbook in a macro-enabled format, such as .xlsm. Keep a backup before making substantial changes, and verify that the procedure still works as intended.

Why is the Edit button unavailable?
Check whether you selected a macro you can edit and whether its containing workbook or VBA project is available. A macro stored in an add-in or a protected project may not be editable through the ordinary dialog. If it is not your project, ask its owner or consult the add-in’s documentation rather than attempting to bypass protection.

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.