How to Open Visual Basic in Excel Using the VBA Editor

VBA & macros · Updated November 21, 2026

In Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor, or select Developer > Visual Basic. You can use the editor to view and write VBA code, inspect workbook modules, and work with macros. Save your workbook first if you plan to make changes; simply opening the editor does not run a macro.

What You’ll Need

  • Excel desktop for Windows: The steps below are for Microsoft 365. The Visual Basic Editor is a desktop application feature, not an editor in Excel for the web.
  • An open workbook: Open the workbook whose VBA project you want to inspect. You can also open the editor without one, but there will be no workbook project to browse.
  • Optional Developer tab: You do not need this tab if you use Alt+F11. To open the editor from the ribbon, enable Developer if it is not already visible.
  • Permission to use VBA: Some work or school devices restrict macros or VBA tools. If the editor is disabled by an administrator, you may need to ask your IT team.

Step-by-Step

  1. Open Excel and the workbook you want to work with. Start Excel for Microsoft 365 on your Windows computer, then open the relevant file. If the goal is to inspect or edit existing VBA, open the workbook containing that code rather than a blank workbook. A workbook with macros is commonly saved as an Excel Macro-Enabled Workbook (.xlsm); an Excel Binary Workbook (.xlsb) can also contain VBA.

    If you only want to explore the editor, a regular blank workbook is fine. Opening a workbook does not automatically run its macros unless its security settings allow them and you enable them.

  2. Use the keyboard shortcut. Press Alt+F11. This opens the Visual Basic Editor (often called the VBE or VBA editor). Press Alt+F11 again to switch back to Excel. On some laptops, the function keys control hardware features, so you may need to press Fn+Alt+F11 instead.

    If the shortcut does nothing, try the ribbon route in the next step. Keyboard behavior can vary with the laptop’s function-key setting, keyboard layout, or remote-desktop setup.

  3. Open it from the Developer tab if you prefer menus. In Excel, select Developer > Visual Basic. The editor opens in a separate window. If you do not see Developer on the ribbon, keep Excel open and follow the next step to show it.

    The Visual Basic button is the route to the editor; other buttons on the Developer tab, such as Macros or Record Macro, open different features. Choose Visual Basic when you want the coding environment itself.

  4. Turn on the Developer tab if it is missing. In Excel for Windows, select File > Options > Customize Ribbon. Under Main Tabs in the right-hand list, select the checkbox next to Developer, then select OK. The Developer tab should now appear on the ribbon. Select Developer > Visual Basic.

    This setting changes which ribbon tab is shown; it does not enable macros or change the workbook’s security level. If the Customize Ribbon controls are unavailable or locked, the device may be managed by your organization.

  5. Find the workbook’s project in the editor. The editor may open with a pane called Project Explorer on the left. It lists open workbooks as projects, often with names such as VBAProject (Book1). If the pane is not visible, press Ctrl+R in the Visual Basic Editor or choose View > Project Explorer.

    Expand the project’s folders using the plus sign or arrow. Microsoft Excel Objects contains the workbook and worksheet objects; Modules contains standard code modules when the project has any. If you have several files open, check the project name before viewing or changing code.

  6. Open the code you need, or return to Excel. In Project Explorer, double-click an object or module to open its code window. For example, double-click a worksheet object to see code associated with that sheet, or double-click a module to view its procedures. A project may not contain a Modules folder if no standard modules have been added.

    To go back to the worksheet, press Alt+F11 again or click the Excel window. If you edit code, save the workbook in a format that supports macros, such as .xlsm. A standard .xlsx file cannot store VBA code; Excel may warn you if you try to save VBA in that format.

Common Mistakes

  • Looking for Visual Basic in the worksheet ribbon: The editor is opened through Developer > Visual Basic, not through the Home tab. If Developer is missing, enable it under File > Options > Customize Ribbon.
  • Using Excel for the web: The browser version does not provide the desktop Visual Basic Editor for editing VBA projects. Open the file in the Excel desktop app instead.
  • Expecting macros to appear in every file: A workbook can open in the editor even if it has no VBA project code to browse. Check that you opened the right file and expand its project folders.
  • Saving a macro workbook as .xlsx: That format does not retain VBA. Choose an appropriate macro-enabled format when saving code, and read Excel’s format warning rather than discarding the project unintentionally.
  • Changing security settings just to open the editor: You generally do not need to enable macros or select “Trust access to the VBA project object model” simply to open and view the editor. Those settings serve other purposes.

Tips

  • Keep the editor and workbook easy to distinguish. The VBE is a separate window. If it seems to disappear, use Alt+F11 to switch between it and Excel, or check the taskbar for the editor window.
  • Make a copy before editing code. Save a separate copy of the workbook before changing VBA. Macro actions and code edits cannot generally be reversed with Excel’s Ctrl+Z undo command, so a backup gives you a way to recover.
  • Use the Project Explorer to confirm context. When multiple workbooks are open, select the project whose name matches the file you intend to inspect. Code in one workbook may not affect another workbook.
  • Use the Mac route when appropriate. In Excel for Mac, select Developer > Visual Basic. If Developer is hidden, go to Excel > Settings > Ribbon & Toolbar, enable Developer under Main Tabs, and save the change. The shortcut is commonly Option+F11; some keyboards require Fn+Option+F11.
  • Remember the limits of browser Excel. Excel for the web can work with many workbook features, but VBA editing and running macros require the desktop application. If a file is stored online, use the option to open it in the desktop app.

Troubleshooting

  • Alt+F11 does not open anything: Click inside the Excel desktop window and try again. On a laptop, try Fn+Alt+F11. If the function keys are assigned to brightness or media controls, check the keyboard’s Fn-lock setting. You can also select Developer > Visual Basic instead.
  • There is no Developer tab: In Windows Excel, use File > Options > Customize Ribbon, check Developer under Main Tabs, and select OK. In Mac Excel, use Excel > Settings > Ribbon & Toolbar and enable the tab. If the controls are unavailable, ask your organization’s support team whether ribbon settings are managed.
  • The Visual Basic button is unavailable or the editor will not launch: Confirm you are using the installed desktop version of Excel, not a browser tab or a simplified viewer. Close and reopen Excel, then check for Office updates. On a managed computer, an administrator may have restricted VBA; do not try to bypass the policy—contact IT.
  • The editor opens, but the workbook is not listed: Return to Excel and confirm the workbook is open in that same Excel session. In the VBE, show Project Explorer with Ctrl+R or View > Project Explorer. Expand the listed projects. If you opened a file type that cannot contain VBA, such as .xlsx, it will not have saved VBA code.
  • The project appears locked or asks for a password: A VBA project can be protected by its author. If you are authorized to access it, ask the workbook owner for the password or an unlocked copy. Do not assume that changing macro settings will remove project protection.
  • You cannot save your edits: Use File > Save As in Excel and choose Excel Macro-Enabled Workbook (*.xlsm) if the file needs to retain VBA. If the file is read-only or stored in a restricted location, save an authorized working copy to a location where you have permission.

Frequently Asked Questions

What is the keyboard shortcut to open Visual Basic in Excel?

In Excel for Microsoft 365 on Windows, press Alt+F11. Press it again to switch back to Excel. Some laptops require Fn+Alt+F11. On Mac, use Option+F11, sometimes with Fn, or select Developer > Visual Basic.

Can I open the VBA Editor without the Developer tab?

Yes. On Windows, Alt+F11 opens the Visual Basic Editor without requiring the Developer tab. You can enable the tab if you want a visible ribbon command, but it is optional.

Can I use Visual Basic in Excel for the web?

Excel for the web does not include the desktop VBA Editor for creating or editing VBA code. Open the workbook in the Excel desktop app on Windows or Mac to use the editor. A workbook may still be stored in OneDrive or SharePoint while you work on it in the desktop app.

Why is the editor empty when I open it?

The editor can open without code windows displayed, or the selected workbook may have no VBA modules. Open Project Explorer, expand the correct workbook project, and inspect its objects and modules. If the workbook is an .xlsx file, VBA code will not be stored in that file format.

Do I have to enable macros to open the Visual Basic Editor?

No. Opening the editor and running macros are separate actions. You can generally open and inspect the editor without enabling a workbook’s macros. Only enable macros when you trust the file and understand what it will do; follow your organization’s security rules.

Will opening Visual Basic change my workbook?

No. Opening the editor alone does not alter the workbook or run code. Changes happen if you edit the project, run a macro, or make another change and save the file. Keep a backup before editing or running code, since Ctrl+Z does not undo macro actions.

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.