VBA Keyboard Shortcut: Open the Editor Fast
In this article
The keyboard shortcut to open the VBA editor in Excel, Word, PowerPoint, Outlook, Access, and most other Microsoft Office desktop apps is Alt + F11. Press it once and the Visual Basic for Applications (VBA) integrated development environment (IDE) opens in its own window. Press Alt + F11 again to switch back to the application. That single shortcut is the answer most people are looking for, and it works the same across the Office desktop suite on Windows. On a Mac, the equivalent is Option + F11 in most Office for Mac apps, though the exact behavior can vary by version and by whether the function keys are set to standard function behavior or to media controls.
What You'll Need
- A desktop installation of Microsoft Office (Excel, Word, PowerPoint, Outlook, or Access) on Windows or Mac. The online/browser versions of Office do not include the VBA editor, so Alt + F11 will not open anything there.
- A keyboard with a working F11 key. On laptops, F11 may be shared with a media or brightness function; you may need to hold the Fn key (Fn + Alt + F11) or change the function-key behavior in your laptop's settings.
- Macros enabled in the application. If macros are disabled by policy, the editor may open but code will not run. This is common on managed work computers.
Step-by-Step
- Open the Office app where you want to work with VBA — for example, Excel with the workbook you want to automate.
- Make sure the application window is active (click once on the document area) so the keystroke is received by the right program.
- Press and hold Alt, then tap F11. On a Mac, hold Option and tap F11. If nothing happens on a laptop, try Fn + Alt + F11.
- The VBA editor opens in a separate window. If it does not appear, check the Windows taskbar or the Mac menu bar for a new "Microsoft Visual Basic for Applications" window — it may have opened behind the main app.
- Inside the editor, use the Project Explorer (usually on the left; if hidden, open it from the View menu) to find your workbook or document and its modules. Double-click a module to see its code, or right-click the project and insert a new module.
- To run code, place the cursor inside a subroutine and press F5, or use the Run menu. To step through code line by line, press F8.
- To return to the main application, press Alt + F11 again (or Option + F11 on Mac). The editor stays open in the background with your code intact.
- Save your work in both places: save the document normally, and save the VBA project from the editor with Ctrl + S (Windows) or Command + S (Mac). In Excel, macro-enabled workbooks must be saved as .xlsm to keep the code.
Common Mistakes
- Pressing F11 alone. In Excel, F11 by itself inserts a chart sheet. In PowerPoint, F11 starts a slideshow. You need the Alt (or Option) modifier.
- Using the wrong app. The online versions of Word, Excel, and PowerPoint have no VBA editor, so the shortcut does nothing there. Use the desktop app.
- Laptop function keys. Many laptops map F11 to a media or display function. If Alt + F11 does nothing, try Fn + Alt + F11, or check the laptop's keyboard settings for a function-lock option.
- Expecting the editor in every Office app. Outlook uses VBA but the editor is the same; some apps such as OneNote do not offer VBA at all. If the shortcut fails in an app, that app likely has no VBA support.
- Forgetting to enable macros. If macros are blocked by Trust Center settings or by organizational policy, code will not run even though the editor opens. Check the Trust Center settings in the app's options.
- Saving as .xlsx. A standard .xlsx workbook strips VBA code when saved. Use .xlsm (macro-enabled) or .xlsb if you need to keep macros.
Tips
- Use Alt + F11 as a toggle: it switches between the host application and the VBA editor without closing either.
- Inside the editor, F5 runs the current procedure, F8 steps through one line at a time, and Ctrl + Break (Windows) stops a running macro. On Mac, use Command + . (period) to stop execution.
- If the Project Explorer or Properties window is missing, open the View menu in the VBA editor and enable them there.
- Keep the Immediate Window visible (View > Immediate Window) for quick debugging with
Debug.Printand for testing expressions. - On Mac, if Option + F11 does not work, check whether the function keys are set to standard function keys in System Settings > Keyboard. With media keys active, you may need Fn + Option + F11.
- Use the editor's built-in help: place the cursor on a keyword and press F1 to open the relevant VBA reference page.
Troubleshooting
If Alt + F11 does nothing, work through these checks in order:
- Click the document window first. Keyboard shortcuts only reach the active window. If a dialog box is open, close it and try again.
- Try the Fn key. On laptops, press Fn + Alt + F11. If that works, consider enabling function-lock (often Fn + Esc) so plain F11 works next time.
- Confirm you are in the desktop app. The browser versions of Office do not include VBA. Look for the installed application in your Start menu or Applications folder.
- Check macro settings. Open the app's options, go to Trust Center > Trust Center Settings > Macro Settings, and confirm macros are not fully disabled. On a work computer, this may be locked by your IT department; contact them rather than trying to bypass it.
- Restart the application. Close the app completely and reopen it, then try the shortcut again.
- Repair Office. If the editor still will not open, use the official repair option in Windows Settings > Apps > Installed apps > Microsoft Office > Modify > Repair. On Mac, reinstall Office from the official installer.
If the editor opens but code will not run, check that the file is saved in a macro-enabled format and that the code is in a standard module or the correct event procedure. If a macro is blocked by security policy, the fix is with your administrator, not a workaround.
Frequently Asked Questions
What is the keyboard shortcut for the VBA editor?
Alt + F11 on Windows and Option + F11 on Mac in the desktop Office apps. On some laptops you need Fn + Alt + F11.
Why does Alt + F11 not open the VBA editor?
The most common reasons are using the browser version of Office, the F11 key being mapped to a media function on a laptop, or a dialog box holding focus. Click the document, try Fn + Alt + F11, and confirm you are in the desktop app.
Does the VBA shortcut work in Excel Online?
No. Excel for the web does not include the VBA editor. You need the desktop version of Excel.
How do I run a macro once the editor is open?
Place the cursor inside the subroutine and press F5, or use Run > Run Sub/UserForm. To step through line by line, press F8.
Can I change the VBA editor shortcut?
No, Alt + F11 is fixed in Office and cannot be reassigned through the normal options. You can create a Quick Access Toolbar button or a ribbon button that opens the editor instead, but the keystroke itself is not customizable.
Why is my code missing after I save?
You likely saved as .xlsx, which does not store macros. Save as .xlsm (macro-enabled workbook) in Excel, or the equivalent macro-enabled format in other apps, to keep your VBA code.