Excel VBA Macro Shortcut: How to Assign and Use It

VBA & macros · Updated November 19, 2026

In Excel for Microsoft 365 on Windows, assign a shortcut to a VBA macro by choosing Developer > Code > Macros, selecting the macro, clicking Options, and entering a letter. Excel runs it with Ctrl+letter, or Ctrl+Shift+letter if you enter an uppercase letter. You can also open the Macros dialog with Alt+F8 and run a macro from there.

What an Excel macro shortcut does

A macro shortcut is a keyboard combination that calls a specific VBA procedure. Instead of opening the macro list and selecting a name each time, you press the assigned combination while working in Excel. This is handy for a routine action you repeat, such as formatting a report or preparing a worksheet for printing.

The shortcut does not create or record a macro; it only provides a way to run one that already exists. If you have not made a macro yet, you can record one with Developer > Code > Record Macro, or write a VBA procedure in the Visual Basic Editor. A macro must be saved in a location Excel can access, and it must be enabled to run.

For one-time use, the shortcut is optional: press Alt+F8, choose a macro, and click Run. The keyboard shortcut is most useful when the macro is safe to run repeatedly and its name or purpose is already familiar.

Assign a shortcut to an existing macro

  1. Open the workbook containing the macro in desktop Excel for Windows.
  2. Choose Developer > Code > Macros. If the Developer tab is missing, enable it through File > Options > Customize Ribbon, then select the Developer check box.
  3. Select the macro in the list and click Options.
  4. Enter a letter in the Shortcut key box. A lowercase letter assigns Ctrl+letter; an uppercase letter assigns Ctrl+Shift+letter.
  5. Optionally enter a description, then click OK and close the Macros dialog.

Try the shortcut after closing the dialog. For example, entering a lowercase m assigns Ctrl+M. Excel may warn that the combination is already in use; think carefully before replacing a built-in shortcut. A description can help identify why a macro was created, but it does not change how the shortcut works.

These steps apply to desktop Excel. In Excel for Mac, use the Macros dialog and its Options button to set a shortcut; the key combination differs from Windows and is generally Option+Command+letter. The precise keys available can depend on the Excel for Mac version and keyboard layout, so use the combination indicated by the dialog and test it in that version.

Record a macro and give it a shortcut

If the action is not yet saved as a macro, Excel can record many worksheet actions and assign a shortcut as part of the recording setup. Choose Developer > Code > Record Macro. In the dialog, give the macro a meaningful name, choose where to store it, and enter a shortcut letter if appropriate. Click OK, perform the actions you want recorded, and then choose Developer > Code > Stop Recording.

Recording captures supported actions, not your intentions. For example, a recorded selection of a particular range may keep targeting that same range, even if you later want the macro to act on whichever cells are selected. Review the result before relying on it for a recurring task. The Visual Basic Editor lets you inspect or revise the generated code, but VBA editing is a separate step from assigning the shortcut.

Choose a shortcut that is easy to remember but unlikely to conflict with Excel commands. A two-step workflow can be sensible: record the macro without a shortcut, test it on a copy, then assign a shortcut once you know what it does and where it operates.

Choose where the macro is stored

The storage choice determines which workbooks can use the macro. When you assign a shortcut, it is associated with the macro in its storage location; it does not automatically become a universal Excel shortcut.

  • This Workbook: The macro is saved with the current workbook. The shortcut is useful when that workbook is open, but the macro generally travels with the file rather than being available in unrelated workbooks. Save a workbook containing VBA as an Excel Macro-Enabled Workbook (.xlsm), or use another macro-capable format such as .xlsb. Saving it as .xlsx removes its VBA project.
  • Personal Macro Workbook: Excel stores the macro in PERSONAL.XLSB, a hidden workbook that opens when Excel starts. This makes personal utility macros available across workbooks on that computer, but it does not make them available to other people who receive an ordinary workbook.
  • New Workbook: Excel puts the macro in a separate workbook created for the recording. Save that workbook in a macro-capable format if you want to keep the code.

For a macro intended only for one report, storing it with that report is usually clearer. For a general helper you use in many files, PERSONAL.XLSB may be more convenient. If you share a file containing VBA, tell recipients what the macro does and how to access it; they may need to enable macros under their organization’s security rules.

Shortcut conflicts and choosing a safe key

Excel’s assigned shortcut can take precedence over an existing Excel shortcut while the macro is available. For example, Ctrl+S is the normal Save command, so assigning a macro to that combination can interfere with saving. Avoid familiar commands such as Ctrl+C, Ctrl+V, Ctrl+Z, Ctrl+P, and Ctrl+S. An uppercase letter in the shortcut box uses the Shift modifier, which can reduce clashes, though it does not guarantee that a combination is unused.

Before choosing a key, consider these factors:

  • Frequency: Reserve a convenient combination for a task you actually repeat.
  • Risk: Avoid a one-key action for a macro that deletes, overwrites, or moves important data.
  • Memory: Use a letter associated with the task, provided the combination is not already important to your workflow.
  • Sharing: A shortcut attached to a macro in a particular file may not follow the user into other workbooks in the way a Personal Macro Workbook shortcut does.

Excel does not provide a separate global hotkey manager for VBA macros. If a shortcut behaves unexpectedly, check which workbook contains the macro, whether it is open, and whether another macro or Excel command uses the same key.

Run a macro from the dialog or another control

A shortcut is only one way to run VBA. On Windows, Alt+F8 opens the Macro dialog, where you can select a macro and click Run. This is a useful fallback when you forget a shortcut or want to confirm the macro’s name. The Developer tab also provides access to macros and recording tools.

You can also assign a macro to a worksheet button or a shape. That can make a task easier for colleagues who do not know the keyboard combination. A button is visible on the sheet, while a shortcut can be faster for someone who already knows it. These options do not change the macro’s code or bypass macro security; Excel still needs to be able to run the VBA.

Excel for the web can open and edit many workbook types, but it cannot create, edit, or run VBA macros. To run a VBA macro, open the file in the desktop Excel application. Office Scripts are a different automation option available in supported Microsoft 365 environments; they are not VBA macros and do not use the same macro shortcut assignment.

Inspecting a simple VBA macro

A VBA macro is usually a procedure beginning with Sub and ending with End Sub. The following example displays a message when run. It illustrates the kind of procedure that can be selected in the Macros dialog; it does not modify worksheet data.

Sub ShowReminder()
    Dim reminder As String
    ' Display a simple message when the macro runs.
    reminder = "Check the report before sharing it."
    MsgBox reminder
End Sub

To inspect or edit VBA in desktop Excel for Windows, open the Visual Basic Editor with Alt+F11. On Mac, the editor shortcut is commonly Option+F11, though some keyboards require the Fn key or a different setting. A macro must be in a standard module or otherwise exposed appropriately to appear in the ordinary macro list. Be cautious with code from sources you do not trust: macros can change workbook contents and may interact with files or other resources.

Save a copy of the workbook before running a macro that changes data. Excel cannot undo a macro’s actions with Ctrl+Z, even when the macro was launched by a shortcut. The example above only displays a message, but the same safeguard matters for macros that edit cells, delete sheets, or reformat a large range.

Common problems and fixes

  • The macro is missing from the list: Check that the correct workbook is open, that the code is saved in a suitable location, and that the procedure is available as a macro. A procedure declared Private, for instance, is not listed like a public macro.
  • The shortcut does nothing: Confirm the workbook containing the macro is open, try running the macro through Alt+F8, and check whether Excel has blocked macros. On a laptop, the function-key row or keyboard layout may also affect key combinations used to open dialogs.
  • The shortcut runs the wrong command: Revisit Macro Options and choose a different letter. The chosen combination may conflict with a built-in Excel shortcut or another macro.
  • The macro disappears after saving: Check the file type. An .xlsx file cannot preserve VBA code; use a macro-enabled format such as .xlsm when the workbook needs to retain its macro.
  • The shortcut works on one computer but not another: Check the workbook’s macro security settings, file format, and whether the macro is stored in PERSONAL.XLSB rather than in the shared workbook. Personal Macro Workbook content is local to that Excel installation.

When troubleshooting, first try the macro from Alt+F8. If it runs there, the code is probably available and the problem is more likely the shortcut assignment or a key conflict. If it does not run there, investigate the workbook, code, and macro security before changing the shortcut.

Frequently Asked Questions

What is the default shortcut to run a macro in Excel?
There is no single default shortcut for every macro. Assign one through Developer > Code > Macros > Options, or open the macro list with Alt+F8 and run the selected macro.

Can I use Ctrl+Shift for an Excel macro shortcut?
Yes. In the Macro Options dialog, enter an uppercase letter to assign Ctrl+Shift+letter on Windows. Choose a combination that does not disrupt a shortcut you rely on.

How do I run an Excel macro on a Mac?
Use the desktop Excel for Mac application and run it from the Macros dialog, or assign a shortcut in that dialog’s Options. Mac shortcut keys differ from Windows; Excel for Mac commonly uses Option+Command+letter for an assigned macro shortcut.

Can I run a VBA macro in Excel for the web?
No. Excel for the web does not run VBA macros. Open the workbook in desktop Excel for Windows or Mac to use its VBA macro.

Why did my macro shortcut stop working?
Common causes include the workbook containing the macro being closed, macros being blocked, the workbook being saved as .xlsx, or a conflicting shortcut. Try Alt+F8 first to determine whether the macro itself is available.

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.