Lesson 19 of 60 – Assigning a Macro to a Keyboard Shortcut
32%

Assigning a Macro to a Keyboard Shortcut

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.

Note: In this lesson, you will learn how to assign a macro to a keyboard shortcut, run the macro using the shortcut, change the shortcut, and use keyboard shortcuts in practical Excel automation.

1. What is a Keyboard Shortcut?

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.

2. Why Assign a Macro to a Shortcut?

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

3. Example of a Macro Shortcut

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.

4. Prepare a 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.

5. Open the Macros Dialog Box

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.

6. Select the Macro

Select the macro to which you want to assign a keyboard shortcut.

For example:

WelcomeMessage

Make sure you select the correct macro before continuing.

7. Click Options

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.

8. Macro Options Dialog Box

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.

9. Enter a Shortcut Key

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.

10. Lowercase and Uppercase Shortcut Keys

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.

11. Add a Macro Description

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.

12. Save the Shortcut

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

13. Test the Keyboard Shortcut

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.

14. Running a Formatting 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.

15. Running a Data Entry Macro

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

16. Running a Calculation Macro

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.

17. Running a Report Macro

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.

18. Shortcut and Existing Excel Commands

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.

19. Changing a Macro Shortcut

You can change the shortcut assigned to a macro.

The general process is:

Developer → Macros
       ↓
Select Macro
       ↓
Options
       ↓
Change Shortcut
       ↓
OK

20. Removing a Macro Shortcut

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.

21. Shortcut for Student Result System

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

22. Shortcut for Report Preparation

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

23. Advantages of Macro Shortcuts

Keyboard shortcuts provide several advantages:

  • Quick access to macros
  • Reduces repeated menu navigation
  • Useful for frequently used tasks
  • Easy to remember after practice
  • Can improve workflow speed

24. Limitation of Macro Shortcuts

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.

25. Testing a Keyboard Shortcut

After assigning a shortcut, test it carefully:

  1. Save the workbook.
  2. Return to the worksheet.
  3. Press the assigned shortcut.
  4. Check whether the macro runs.
  5. Check the output.

If the expected action does not occur, check the macro and its assigned shortcut.

26. Best Practices

Follow these practices when assigning macro shortcuts:

  • Use shortcuts only for frequently used macros.
  • Choose memorable shortcut combinations.
  • Avoid interfering with important Excel shortcuts.
  • Keep a consistent shortcut system in larger projects.
  • Test the shortcut after assigning it.
  • Save the workbook as an .xlsm file.

27. Complete Shortcut Assignment Workflow

The complete process is:

Create Macro
     ↓
Developer → Macros
     ↓
Select Macro
     ↓
Options
     ↓
Enter Shortcut
     ↓
Add Description
     ↓
OK
     ↓
Test Shortcut

28. Shortcut vs Button vs Shape

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.

29. Practical Exercise

Try the following exercise:

  1. Create a simple macro that displays a message.
  2. Open Developer → Macros.
  3. Select your macro.
  4. Click Options.
  5. Assign a shortcut such as Ctrl + Shift + M.
  6. Add a description for the macro.
  7. Click OK.
  8. Return to the worksheet.
  9. Press the assigned shortcut.
  10. Check whether the macro runs.

This exercise will help you understand how keyboard shortcuts can be used to run Excel macros.

30. Complete Understanding of Macro Keyboard Shortcuts

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

📌 Key Points

  • A keyboard shortcut is a combination of keys used to perform an action quickly.
  • Excel macros can be assigned to keyboard shortcuts.
  • Macro shortcuts can be configured through the Macro Options dialog box.
  • Shortcuts are useful for frequently used macros.
  • Choose shortcuts carefully to avoid interfering with existing Excel commands.
  • You can change a macro's shortcut later.
  • Buttons, shapes, and keyboard shortcuts are different ways to run macros.

🧠 Quick Quiz

Question: Where can you assign a keyboard shortcut to an Excel macro?