In Excel for Microsoft 365 on Windows, press Alt+F11 to open the Visual Basic Editor (VBE), or choose Developer > Visual Basic. If the Developer tab is missing, enable it in Excel’s ribbon settings first. The VBE is where you view, write, and edit VBA code associated with a workbook; it is separate from the worksheet grid.
What You’ll Need
- A desktop version of Excel. Excel for the web does not open or edit the VBA editor; use Excel for Windows or Mac instead.
- A workbook, if you want to inspect or edit code tied to a particular file. You can also open the editor without a workbook open.
- Permission to access the workbook’s VBA project. A project may be password-protected by its creator, even when you can open the workbook itself.
You do not need to enable macros just to open the editor. However, macro security settings can affect whether VBA code runs. Be cautious with code from sources you do not trust, and do not lower security settings simply to make the editor appear.
Step-by-Step
- Open Excel for desktop. Start Excel from the Windows Start menu or your Mac’s Applications folder. If you already have the workbook open in the desktop app, leave it open; the VBE can then show its project as soon as it starts. If the workbook is in a browser, choose the option to open it in the desktop app, if available.
- Use the Windows keyboard shortcut. Press Alt+F11. On most Windows keyboards, this opens the Visual Basic Editor immediately. If your keyboard’s function keys control brightness or media, hold Fn as well, so the F11 key sends its standard function-key command. On some laptops, the Fn-lock setting changes whether that extra key is required.
- Try the ribbon command if you prefer menus. In the Excel window, select the Developer tab, then select Visual Basic in the Code group. The editor opens in a separate window. If you cannot see Developer, continue to the next steps to show the tab; it is commonly hidden by default.
- Show Developer in Excel for Windows. In Excel, select File > Options > Customize Ribbon. Under Main Tabs in the right-hand list, select the checkbox beside Developer, then select OK. The Developer tab should now appear on the ribbon. Select Developer > Visual Basic to open the editor.
- Use the Mac route if you are on Excel for Mac. Select Developer > Visual Basic if the tab is already visible. The usual keyboard shortcut is Option+F11; depending on your keyboard settings, you may also need to hold Fn. If Developer is missing, open Excel > Settings > Ribbon & Toolbar, select the Developer checkbox in the list of main tabs, and save the change. In some older Mac releases, the settings item is called Preferences rather than Settings.
- Find the workbook’s project in the editor. The VBE often shows the Project Explorer on the left. If it is hidden, press Ctrl+R on Windows or use View > Project Explorer. On Mac, use View > Project Explorer if the shortcut differs or is unavailable. Look for a project named VBAProject followed by the workbook name. If several workbooks are open, check the names carefully before opening a code item.
- Open a code module when you need to inspect code. In Project Explorer, expand the project by selecting its plus sign or disclosure arrow. Double-click a sheet, ThisWorkbook, or a listed module to display its code window. A sheet or ThisWorkbook module holds code associated with that workbook object; a standard module is commonly used for general macros. Opening the VBE alone does not run any code.
- Return to Excel when you are finished. Close the VBE window or switch back to the Excel window. The editor and workbook are separate windows, so minimizing or closing the editor is not the same as closing the workbook. If you changed code, save the workbook in a macro-capable format such as Excel Macro-Enabled Workbook (.xlsm) to retain VBA.
On Mac, the exact appearance and window arrangement can differ from Windows, but the Developer > Visual Basic command serves the same purpose. The editor is part of the desktop Excel application, not a separate download for ordinary Microsoft 365 installations.
Common Mistakes
Looking for Developer without turning it on. The Developer tab is often hidden when Excel is installed. Its absence does not mean that your Excel edition cannot use VBA. Enable the tab through the ribbon customization settings for your operating system, then look for Visual Basic there.
Confusing the VBE with the macro list. Alt+F8 opens the Macro dialog, which is useful for viewing and running available macros; it does not open the code editor. Use Alt+F11 on Windows, or the Visual Basic command on the Developer tab, when you want the VBE.
Trying to use VBA in Excel for the web. The browser version can work with many workbook features, but it cannot open or edit VBA projects. Open the file in desktop Excel instead. If you only have browser access, ask the workbook owner or your administrator whether desktop Excel is available.
Assuming opening the editor runs a macro. Opening the VBE merely displays the programming environment. A macro runs only when it is started by an appropriate command or event, and Excel’s security settings may block code from running. Do not run unfamiliar macros simply because the editor is open.
Saving code in a format that drops it. If you add or change VBA, saving the workbook as a regular .xlsx file removes its VBA project. Choose .xlsm for a macro-enabled workbook, or another appropriate macro-capable format when required. If Excel warns that features cannot be saved, review the format choice before confirming.
Tips
Keep the workbook open before opening the editor. This makes it easier to identify the correct VBAProject in Project Explorer, especially if several files are open. A workbook can have worksheet modules, a ThisWorkbook module, and standard modules, so expand the project rather than assuming all code sits in one place.
Use the editor’s navigation windows. If Project Explorer is missing, use View > Project Explorer; on Windows, Ctrl+R is a convenient toggle. The Properties window, available from View > Properties Window or with F4 in common Windows configurations, displays settings for the selected project item. These windows help orient you but are not required just to open the VBE.
Make a copy before editing code. Save a separate copy of the workbook before changing VBA. Excel’s Ctrl+Z undo history does not undo VBA macro actions, and code changes can affect the workbook’s behavior. If you are editing a shared file, coordinate with its owner so you do not overwrite another person’s changes.
Distinguish editor access from macro permissions. You can often inspect the VBE even when macros are disabled. Conversely, a workbook’s project may be locked for viewing, or your organization may restrict VBA. Use only code you trust and follow your organization’s security guidance rather than changing global settings to bypass a warning.
Remember the Mac keyboard difference. Windows users generally press Alt+F11; Mac users use Option+F11, sometimes with Fn depending on the keyboard. If a shortcut is intercepted by a system function or does not work, use the Developer tab’s Visual Basic command instead. The ribbon command is also helpful when you are unsure which key mapping is active.
Troubleshooting
Alt+F11 does nothing. Confirm that you are using the desktop Windows version of Excel, not Excel in a browser. Try holding Fn with Alt+F11 if the keyboard has special F-key actions, or use Developer > Visual Basic. If Developer is absent, enable it using File > Options > Customize Ribbon and select its checkbox.
The Developer tab does not appear after enabling it. Check that you selected Developer under Main Tabs, then select OK to apply the change. If you have multiple Excel windows or instances open, check the ribbon in the window you are currently using. On a managed computer, some settings may be controlled by an administrator; contact them if the checkbox is unavailable or the change will not stick.
The editor opens, but the workbook is not listed. Return to Excel and confirm that the intended workbook is open in the same desktop session. In Project Explorer, look for a VBAProject entry using the workbook’s name. If the pane is missing, use View > Project Explorer. For a workbook with no VBA project, there may be no code modules to expand; opening the editor does not automatically create a macro.
The project is listed but will not expand or show code. The VBA project may be locked for viewing with a password, or the file may not contain an accessible project. Ask the workbook’s creator or administrator for access rather than trying to bypass a lock. If the workbook was downloaded, make sure you are opening the intended file and not a preview or a copy saved in a format that discarded its macros.
Excel displays a security warning or blocks macros. This is different from being unable to open the editor. Follow the warning and your organization’s policy; do not enable content in a file unless you trust its source and understand why it needs macros. If you need the code for legitimate work, ask the file owner or IT support about a safe, approved way to review it.
You are working in a browser or on a device without desktop Excel. Excel for the web cannot open the VBA editor. Use a Windows or Mac desktop installation. If you are on a Mac and the shortcut is the problem, use Developer > Visual Basic; if the tab is hidden, enable it in Excel’s Ribbon & Toolbar settings.
Frequently Asked Questions
What is the shortcut to open the Visual Basic Editor in Excel?
In Excel for Windows, press Alt+F11. On Excel for Mac, use Option+F11; depending on keyboard settings, you may need to hold Fn as well. You can also open it from Developer > Visual Basic.
Why can’t I see the Developer tab?
It is commonly hidden by default. On Windows, go to File > Options > Customize Ribbon and check Developer under Main Tabs. On Mac, open Excel > Settings or Preferences > Ribbon & Toolbar and enable Developer.
Can I open the VBA editor in Excel for the web?
No. Excel for the web does not provide the VBA editor for viewing or editing VBA projects. Open the workbook in desktop Excel for Windows or Mac.
Do I need to enable macros to open the editor?
No. Opening the editor and running macros are separate actions. Macro settings may block code from running, and a VBA project may also be locked for viewing, but enabling macros is not a prerequisite for opening the VBE.
How do I open a workbook’s code after launching the editor?
Show Project Explorer using View > Project Explorer, expand the workbook’s VBAProject, and double-click a sheet, ThisWorkbook, or a module. If the project is locked, ask its owner for permission to view it.
Will my VBA code stay if I save as .xlsx?
No. The .xlsx format does not retain VBA code. Save a workbook containing VBA as .xlsm, and keep a backup before making code changes.
Related
- How to Insert a Line in a Word Footer on Every Page
- How to Insert a Line in a Word Header Step by Step
- How to Insert a Line in a Word Table: Step by Step
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Not Responding and Won’t Close? Try These FixesIf Excel says Not Responding and will not close, first give it a minute if it may be…
- Compare Documents in Word 365: A Practical GuideTo compare two files in Word 365 on Windows, open Word and choose Review > Compare > Compare,…
- How to Open SharePoint Files in the Excel AppTo open a SharePoint workbook in the desktop Excel app, find the file in its SharePoint document library,…
- Excel Data Validation: Can You Select Multiple Items?No. In Excel for Microsoft 365, a data-validation drop-down list lets you choose one item for a cell…
- Excel Conditional Formatting Question Mark ExplainedIn Excel conditional formatting, a question mark (?) is a wildcard in criteria: it matches exactly one character.…
- How to Change View Size in Outlook Email on Any ScreenTo change the size of an email in Outlook, adjust message zoom in classic Outlook for Windows, or…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.