Run a macro from a form button in Excel – How to

Run a macro from a form button in Excel – How to

Run a macro from a form button in Excel - How to

This tutorial shows you how to run a macro from a form button in Excel.

If you do not have a macro to use, then create one. Or, just go through our Hello World lesson. In fact, we will use the macro from our Hello World lesson, in this tutorial.

Steps to run a macro from a form button

Firstly, open your macro file, and follow the steps below to run a macro from a form button.

Steps 1 to 3
Steps 1 to 3 - Run a macro - Insert form button
Insert a Form Controls button. Remember, use the file that contains the macro you want to use.
  1. Click Developer from the main menu. The Developer ribbon appears.
  2. From the Controls group, click Insert. This opens the Controls dropdown menu.
  3. Select the Button control, from the Form Controls section. After that, click somewhere on the sheet. As a result, the Assign Macro dialog box opens.
Steps 4 and 5
Steps 4 and 5 - Assign macro dialog box
Assign macro dialog box.
  1. In the Assign Macro dialog box, select the macro you would like to run.
  2. Finally, click OK. The button appears on the sheet.

Test it out

So, to test out the form button, simply click somewhere on the sheet, to deselect the button. Then, click on the button. Your macro should run, just like ours below.

Sheet with a form control button and Hello, world! text, from the macro
Soon as you press the button, Hellow, world! appears on the cell you select.

Right-click on the button to reveal the shortcut menu. If you want to resize the button, then just click out of the shortcut menu. Also, you can edit the button text from the shortcut menu.


Success!

So, did it work for you? If so, then congratulations. Otherwise, give it another shot.


The video

Here is a quick video of this lesson.


Related


Education home

 

Affiliate stuff – Move up and excel with Excel