Excel Effects

Reference guide.

Assign a macro to a command button in Excel – Quick tip

Assign a macro to a command button in Excel

This lesson shows you how to assign a macro to a command button in Excel. A button is a great way to show the user a clickable item on your sheet. Furthermore, it helps you automate tasks in a user friendly manner.

Right-click note

In part of this lesson, you may see the term right-click. When we say right-click, we simply want you to click the button on the right side of the mouse.

Mouse to show click and right-click buttons

If you do not have a right mouse button, then you can generally use a regular click (left-side) and press the keyboard shortcut Shift-F10.

Note: If you do not have a macro to assign, then check out one of the links in our resources section below. After that, come back and continue the lesson. Otherwise, you can just follow along.

Steps to assign a macro to a command button in Excel

Follow the steps below to complete the task of assigning a macro to a command button.

Insert the button

Steps 1 to 3 - Insert the button

  1. So, click Developer from the main menu.
  2. Under the Controls group, select the Insert.
  3. Then, within Form Controls, select the Button form control. And, click somewhere on the sheet.

After you click on the sheet, the Assign Macro dialog box opens.

Assign the macro

Steps 4 and 5 - Assign macro

  1. Also, in the Assign Macro dialog box, select a macro.
  2. And, click OK.

As a result, your button is now inserted on the sheet with an assigned macro. Unfortunately, you may not be able to do too much formatting using Excel's sheet tools.

Inserted button with assigned macro

Edit mode

When you put the button on the sheet, it will appear with selection nodes. Thus, you will have the opportunity to change the size of the button. And, you can rename the button and change the font size of the text.

Run the macro

Before you run the macro, click somewhere on the sheet to take the button out of edit mode. After you do that, you can click on the button to run your macro.

To return to edit mode, hold the control (Ctrl) key and click on the button. Or, just right-click on the button and press Esc to exit the shortcut menu.



Finally, you are good to go!

Additional resources

Assign a macro to a command button in Excel
by Excel Effects :: October 24, 2020


Great Hair Ideas customizable PowerPoint art

GameStop, Inc.

Development Category (English)300x250

Microsoft Surface Book 3