Excel allows you to assign a macro to a keyboard shortcut. After assigning the shortcut, you can run the macro by pressing the selected key combination instead of opening the Macros dialog box.
A keyboard shortcut is a combination of keyboard keys used to perform an action quickly.
For example:
Ctrl + C → Copy
Ctrl + V → Paste
Ctrl + S → Save
Macros can also be assigned to keyboard shortcuts.
A keyboard shortcut provides a quick way to run a macro.
Instead of opening the Developer tab and selecting the macro, you can press the assigned shortcut.
Keyboard Shortcut
↓
Run Macro
↓
Perform Task
Suppose you have a macro named:
FormatReport
You can assign a shortcut such as:
Ctrl + Shift + F
When you press the assigned shortcut, Excel runs the macro.
First, create a macro that you want to run using a keyboard shortcut.
For example:
Sub WelcomeMessage()
MsgBox "Welcome to Excel Automation!"
End Sub
This macro displays a message when it runs.
To assign a keyboard shortcut to a macro, open the Macro dialog box.
Go to:
Developer → Macros
You will see the macros available in the workbook.
Select the macro to which you want to assign a keyboard shortcut.
For example:
WelcomeMessage
Make sure you select the correct macro before continuing.
After selecting the macro, click the Options button in the Macros dialog box.
The Macro Options dialog box contains settings for the macro, including the keyboard shortcut.
The Macro Options dialog box allows you to specify a shortcut key for the selected macro.
You can also enter a description for the macro.
This helps document the purpose of the macro.
In the Shortcut key box, enter a letter that will be used with the Ctrl key.
For example:
Ctrl + Shift + F
When assigning a shortcut, choose one that is easy to remember and does not interfere with important shortcuts you regularly use.
Excel provides different shortcut behavior depending on whether the shortcut letter is entered as a lowercase or uppercase letter.
An uppercase shortcut generally uses Ctrl + Shift + Letter, while a lowercase shortcut uses Ctrl + Letter.
Choose the shortcut carefully because existing Excel shortcuts may already use the same key combination.
The Macro Options dialog box also provides a description field.
You can write a short explanation such as:
Formats the student report
A description helps you remember what the macro does.
After entering the shortcut and description, click OK.
The shortcut is now associated with the selected macro in that workbook.
Select Macro
↓
Options
↓
Enter Shortcut
↓
OK
Close the Macro dialog box and press the assigned keyboard shortcut.
Excel should execute the macro.
For example, if you assigned Ctrl + Shift + F, press those keys together to run the macro.
Keyboard shortcuts are useful for frequently used formatting macros.
For example:
Ctrl + Shift + F
↓
FormatReport Macro
↓
Apply Report Formatting
This can make repeated formatting tasks faster.
A keyboard shortcut can also run a data-entry macro.
For example, a macro can prepare a new data-entry row or perform a repeated data-entry operation.
Shortcut
↓
Data Entry Macro
↓
Prepare Data Entry Area
You can assign a shortcut to a macro that performs calculations.
For example:
Ctrl + Shift + C
↓
CalculateResult
↓
Calculate Total
↓
Calculate Percentage
This is useful when calculations are performed frequently.
A report-generation macro can also be assigned to a keyboard shortcut.
For example, pressing the shortcut can run a macro that prepares a formatted report.
This provides quick access to the report-generation task.
Some keyboard shortcuts are already used by Excel.
When assigning a macro shortcut, choose the combination carefully so that you do not unintentionally replace a shortcut that you regularly use.
A dedicated shortcut such as Ctrl + Shift + Letter can be useful for custom macros.
You can change the shortcut assigned to a macro.
The general process is:
Developer → Macros
↓
Select Macro
↓
Options
↓
Change Shortcut
↓
OK
If you no longer want a shortcut for a macro, you can modify the macro's shortcut setting from the Macro Options dialog box.
The macro itself can continue to exist even when you no longer use a keyboard shortcut to run it.
Suppose you have a student result workbook with a macro named CalculateResult.
You can assign a keyboard shortcut to quickly run the calculation macro.
Keyboard Shortcut
↓
CalculateResult
↓
Total
↓
Percentage
↓
Result
Suppose a monthly report requires several repeated operations.
You can create a macro for the process and assign a keyboard shortcut to run it quickly.
Shortcut
↓
GenerateReport
↓
Format Data
↓
Calculate Totals
↓
Prepare Report
Keyboard shortcuts provide several advantages:
Keyboard shortcuts are convenient, but they can become difficult to remember when many macros use different shortcuts.
It is better to assign shortcuts only to frequently used macros and use buttons or shapes for other macros when appropriate.
After assigning a shortcut, test it carefully:
If the expected action does not occur, check the macro and its assigned shortcut.
Follow these practices when assigning macro shortcuts:
The complete process is:
Create Macro
↓
Developer → Macros
↓
Select Macro
↓
Options
↓
Enter Shortcut
↓
Add Description
↓
OK
↓
Test Shortcut
There are different ways to run an Excel macro.
| Method | How to Run | Useful For |
|---|---|---|
| Keyboard Shortcut | Press assigned keys | Frequently used tasks |
| Button | Click button | Simple controls |
| Shape | Click shape | Designed worksheets |
All three methods can provide quick access to macros.
Try the following exercise:
This exercise will help you understand how keyboard shortcuts can be used to run Excel macros.
A macro can be assigned to a keyboard shortcut so that it can be executed quickly from the keyboard. This is especially useful for macros that are used frequently.
You can assign, change, and manage macro shortcuts through the Macro Options dialog box.
Select Macro
↓
Options
↓
Assign Shortcut
↓
Press Shortcut
↓
Run Macro
Question: Where can you assign a keyboard shortcut to an Excel macro?