Excel Macro Location: Where VBA Code Is Stored

VBA & macros · Updated November 13, 2026

In Excel for Microsoft 365 on Windows, a macro is usually stored as VBA code inside the workbook that contains it. To find it, open the workbook, press Alt+F11 to open the Visual Basic Editor, then look in Project Explorer under Modules, a worksheet, or ThisWorkbook; macros can also be stored in the Personal Macro Workbook or an add-in.

Where Excel stores a macro

A macro’s location depends on the choice made when it was created. If you record a macro or write VBA, Excel can save it in the current workbook, in the Personal Macro Workbook, or in a new workbook. The first option is the typical choice when the macro is meant to travel with one particular file. The Personal Macro Workbook is useful for routines you want available whenever you use Excel on the same computer. An add-in is often more suitable for distributing reusable tools across workbooks.

There are two related meanings of “location” to keep in mind:

  • Code location: the workbook or add-in project, and the module within that project, where the VBA instructions are stored.
  • File location: the folder on your computer or network where the workbook, Personal Macro Workbook, or add-in is saved.

Finding the code in the editor does not always tell you where the file is saved. To check the file location, use Excel’s File > Info page or File > Save As, as appropriate. The title bar and the file’s folder can also help identify which workbook is open.

How to find a macro in the VBA Editor

Open the workbook that you think contains the macro, then press Alt+F11 on Windows. In the Visual Basic Editor, find the Project Explorer pane. If it is not visible, use View > Project Explorer or press Ctrl+R. Each open workbook or add-in appears as a project, usually named VBAProject followed by the file name.

Expand the project by clicking the plus sign beside it. A typical workbook project can contain folders such as Microsoft Excel Objects and Modules. Expand Modules and double-click a module, such as Module1, to view the code. If the Modules folder is missing, that project may not have a standard code module; the macro could be in a worksheet or workbook object instead.

To check the worksheet and workbook objects, expand Microsoft Excel Objects. Double-click a sheet, such as Sheet1, or ThisWorkbook. These objects can contain event procedures that run in response to actions, such as opening the workbook or changing a cell. Such procedures may not appear in the regular macro list, so checking only the Macros dialog is not a complete search.

For a quick list of macros Excel recognizes, press Alt+F8 on Windows, or choose Developer > Macros. Select the relevant workbook in the Macros in list when needed. Choose a macro and click Edit to open its code in the editor. This is a convenient route for ordinary macros, but it will not necessarily reveal event procedures or every kind of VBA code.

What modules, sheets, and ThisWorkbook mean

VBA code is organized into modules. A standard module is a general-purpose home for procedures you might run directly, such as a routine that formats a report. Excel commonly places recorded macros in a standard module. The procedure’s location in that module does not determine which cells it affects; the instructions in the code do.

Worksheet modules belong to individual sheets. They are commonly used for event procedures tied to a particular sheet, such as reacting when a user changes a cell. The ThisWorkbook module belongs to the workbook as a whole and can hold workbook-level event procedures, such as code that responds when the file opens. These event procedures typically have special names and arguments, and may run automatically when the relevant event occurs.

For example, if a workbook opens and immediately displays a message, the cause could be a workbook-open event procedure in ThisWorkbook. If a normal macro called FormatReport appears under Developer > Macros, its code is more likely in a standard module. These are common patterns, not guarantees; code can call procedures stored elsewhere in the same project.

Choose where a new macro is saved

When recording a macro, Excel asks where to store it. On Windows, use Developer > Record Macro to open the recording dialog, then choose an option from Store macro in. The choices are usually This Workbook, Personal Macro Workbook, and New Workbook. Stop recording from Developer > Stop Recording when the steps are complete.

  • This Workbook: choose this when the macro is meant to work with, or be distributed alongside, the current file.
  • Personal Macro Workbook: choose this for a personal utility you want available in Excel on that computer. It is normally hidden while Excel is open.
  • New Workbook: choose this when you want Excel to create a separate workbook for the recorded macro.

Choosing a storage location does not automatically make a macro suitable for every workbook. A recorded procedure may refer to a particular sheet name, cell range, or file path. If you want to reuse it elsewhere, review what it does and whether its references make sense in the other workbook. Avoid assuming that a macro is portable simply because it appears in the Personal Macro Workbook.

Personal Macro Workbook and add-ins

Excel’s Personal Macro Workbook is named PERSONAL.XLSB. It is a separate, binary-format workbook that Excel loads in the background when you start the application. It is usually hidden so it does not appear as an ordinary open workbook. Macros stored there are generally available in that Excel installation, but the file is not automatically shared with other users or computers.

To inspect it, open the Visual Basic Editor and look for VBAProject (PERSONAL.XLSB) in Project Explorer. You can also use View > Unhide in Excel if the workbook is loaded and hidden. When closing Excel after recording a macro in the Personal Macro Workbook, save changes to it if Excel asks. If you do not save those changes, the new macro may not be there the next time Excel starts.

An Excel add-in is another reusable location. Add-ins are separate files that Excel can load to provide features across workbooks. An add-in may contain VBA code, but not every add-in is a VBA project. If a macro comes from an add-in, its project may appear in Project Explorer while the add-in is loaded. Add-ins are a more deliberate distribution option than a personal workbook, but users may need to install or enable them before the macro is available.

File formats that can keep VBA

A macro-enabled workbook must use a file format that supports VBA. The usual workbook format is .xlsm. Excel Binary Workbook, .xlsb, can also contain macros. A macro-enabled template uses .xltm. By contrast, the standard .xlsx workbook format does not store VBA project code.

If you save a macro-enabled workbook as .xlsx, Excel warns that the VBA project will be removed. Do not proceed with that format if you need to keep the macros. Choose Excel Macro-Enabled Workbook (.xlsm) in Save As for a typical workbook with VBA, or retain the appropriate macro-enabled format already in use. Changing the extension manually in a file name is not a substitute for saving in the correct format.

After saving, check the file name and extension, then close and reopen the saved file if you need to verify that the code remains. If the workbook opens with a security warning or macros disabled, that is a separate issue from whether the VBA code is present in the file.

Common reasons a macro seems missing

A macro that does not appear where expected may be saved in a different project, omitted from the workbook’s file format, or hidden by a setting or security restriction. Use a methodical check rather than immediately recreating it:

  • Confirm that you opened the intended copy of the workbook. Files with similar names can be stored in different folders.
  • In Developer > Macros, check the Macros in list for the current workbook, open workbooks, or Personal Macro Workbook.
  • In Project Explorer, expand each relevant project and inspect Modules, sheet objects, and ThisWorkbook.
  • Check the file extension. If the file was saved as .xlsx after a warning, its VBA code may have been removed.
  • For PERSONAL.XLSB, confirm that it is loaded and that any recent changes were saved when Excel closed.
  • For an add-in, check whether it is installed and loaded. A macro in an unloaded add-in may not be available to run.

Macros can also be unavailable because Excel has disabled them for security. A disabled macro may still be present in the workbook; enabling or inspecting it is different from locating the code. Follow your organization’s security rules, and do not enable macros in an unexpected file merely to see what happens.

Windows, Mac, and Excel for the web

The steps above are for Excel for Microsoft 365 on Windows. On a Mac, Excel also supports VBA and includes a Visual Basic Editor, though keyboard shortcuts can depend on the keyboard and macOS settings. Try Option+F11 to open the editor; on some keyboards you may also need Fn. The Developer tab may need to be enabled in Excel’s ribbon settings. Menu and dialog wording can differ from Windows.

Excel for the web does not let you create, run, or edit VBA macros. A workbook containing VBA can be opened in the browser, but you need the desktop Excel app to work with its VBA code or run it. Use Open in Desktop App, or open the file from the desktop version of Excel. The browser’s inability to run a macro does not by itself mean the code was deleted.

VBA compatibility can also vary between Windows and Mac. Code that depends on Windows-only components, such as certain ActiveX controls or Windows API calls, may not work on a Mac. If a workbook is shared across platforms, check the code’s dependencies and test it in the intended desktop versions before relying on it.

Safety before running or sharing macros

VBA can make changes to workbook contents and, depending on its instructions and environment, interact with files or other resources. Only run macros from a source you trust. If you need to inspect code, open the VBA Editor and read the relevant procedure before running it; unfamiliar code can call procedures elsewhere in the project, so inspect related code too.

Save a copy of the workbook before running a macro that changes data or formatting. Excel cannot undo a macro with Ctrl+Z, so a backup is the practical way to recover the original state. If the file is important, keep an untouched copy in a separate location. When sharing a macro-enabled file, tell recipients that it contains VBA and provide enough context for them to decide whether they trust its source.

Frequently Asked Questions

Where is the macro button in Excel?
On Windows, open the Developer tab and choose Macros. If the Developer tab is not visible, enable it in Excel’s ribbon settings. Alt+F8 opens the macro list on Windows.

Where is the VBA code for a macro?
Press Alt+F11 on Windows to open the Visual Basic Editor. Find the workbook project in Project Explorer, then look in Modules, worksheet objects, and ThisWorkbook. A macro stored in an add-in or PERSONAL.XLSB appears under that project instead.

Are Excel macros saved in the workbook?
Often, yes, if the macro was stored in This Workbook. But Excel can also store macros in PERSONAL.XLSB or an add-in, so the macro may not be inside the workbook you are using.

Why can’t I see my macro in the Macros list?
Check the Macros in selection, the other open workbook projects, and PERSONAL.XLSB or loaded add-ins. Also look in sheet and ThisWorkbook modules: event procedures may not appear in the ordinary macro list.

Can I find or run an Excel macro online?
Excel for the web cannot create, edit, or run VBA macros. Open the workbook in the desktop Excel app to inspect or run its VBA code.

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.