Press Alt + F11 in Excel and the Visual Basic Editor (VBE) opens — that is where all VBA code (macros) lives. From there you can browse modules, search for specific code, and inspect macros stored in the workbook. Note that the shortcut is F11, not F; if Alt + F11 does nothing, see the troubleshooting section below.
What You'll Need
- Excel for Windows (desktop version) — the Visual Basic Editor is not available in Excel for the web or mobile
- The workbook that contains (or may contain) the macros you want to find
- If macros are blocked, enable them via the message bar only for workbooks you trust
Step-by-Step
- Open the workbook in Excel. If a macro was saved in a personal workbook or an add-in, open that file or load the add-in so its code is visible too.
- Press Alt + F11. The Visual Basic Editor opens in a separate window. (On some laptops you may need to hold Fn as well, i.e. Alt + Fn + F11, if F11 is shared with a media key.)
- Show the Project Explorer if it is not visible: press Ctrl + R, or go to View > Project Explorer. This pane lists every open workbook and add-in as a "VBAProject."
- Expand the project for your workbook by clicking the + sign. You'll see folders for the workbook's objects (the ThisWorkbook module and each sheet) and a Modules folder containing standard modules.
- Double-click a module or sheet to open it. Any code attached to that object appears in the code window on the right.
- Search all code at once by pressing Ctrl + F in the editor, typing a keyword (such as a macro name or Sub title), selecting "Current Project" in the Search dropdown, and clicking Find Next.
- List every macro in the workbook from the editor: go to Tools > Macros (or press Alt + F8 from Excel) to see all macro names. Selecting one and clicking Edit jumps straight to its code in the editor.
- Check event code on sheets by double-clicking a sheet name in the Project Explorer — code that runs automatically (like Worksheet_Change) is stored there, not in a standard module.
Menu labels can differ slightly between Excel versions, but Alt + F11, Ctrl + R and Ctrl + F work the same in all modern versions of Excel for Windows.
Common Mistakes
- Pressing Alt + F (which opens Excel's File menu / Office Backstage) instead of Alt + F11 — the F key alone never opens the code editor.
- Looking only in the Modules folder and missing code stored in sheet objects or ThisWorkbook.
- Forgetting that Excel for the web and Excel mobile have no Visual Basic Editor — you must use the desktop program on Windows (or Excel for Mac, which has its own editor).
- Searching only the current module with Ctrl + F instead of setting the search scope to "Current Project."
- Expecting to see code in a plain .xlsx file — macros are only stored in .xlsm (macro-enabled) or .xlsb files.
Tips
- Alt + F8 is the fastest way to list macro names; Alt + F11 takes you to the code itself.
- Press F2 in the editor to open the Object Browser, useful for finding procedures and objects across referenced libraries.
- Use Debug > Compile to check that found code still compiles before you rely on it.
- Right-click a module in the Project Explorer and choose Export File to save a copy of the code as a .bas file — handy for backups.
- Macros stored in the Personal Macro Workbook (PERSONAL.XLSB) only appear in the Project Explorer after that workbook is loaded.
Troubleshooting
- Alt + F11 does nothing: your keyboard's F-keys may default to media functions — try Alt + Fn + F11. On Mac, the equivalent is Option + F11 (or Fn + Option + F11).
- Project shows but says "project is locked" or asks for a password: the code is protected. Only the file's author can unlock it; there is no legitimate way around a VBA password.
- No Modules folder under the project: the workbook simply has no standard macros; check sheet objects and ThisWorkbook for event code, or the workbook genuinely contains none.
- Alt + F11 works but the window is blank: go to View > Project Explorer (Ctrl + R) and double-click a module to open a code pane.
- You're in Excel for the web: VBA is not supported there at all — open the file in the desktop application instead.
Frequently Asked Questions
Is the shortcut Alt + F or Alt + F11?
Alt + F11. Alt + F opens Excel's File menu. The editor shortcut has always used F11.
Where is VBA code stored in a workbook?
Inside the workbook file itself, in VBAProject modules and sheet objects. It only persists in macro-enabled formats like .xlsm and .xlsb.
Can I view VBA code in Excel for the web or mobile?
No. The Visual Basic Editor exists only in the desktop versions of Excel (Windows and Mac).
How do I find a specific macro by name?
Press Alt + F8 in Excel to list all macros, or press Ctrl + F in the editor and search the current project for the name.
Why can't I see the code in a workbook someone sent me?
Either the project is password-protected, the file was saved as .xlsx (which strips macros), or macros are disabled and the file needs to be reopened with content enabled.