Skip to content
Related Articles

Related Articles

Improve Article

Assigning Excel Macro to Objects

  • Last Updated : 06 Jun, 2021

In Excel, a recorded macro can be assigned to different objects like a shape, graphic, or control note. Instead of running the macro from the required tool in ribbon, we can create these objects to run them easily. They get very handy when multiple macros are there. Individual objects can be created for different macros. 

In this article, let’s discuss how can we assign macros to different objects :

1. Assigning Macro to a Shape

It is one of the easiest ways to run a macro is to create any shape in the worksheet and use it for running the macro.

The steps that need to be followed are:

  • Click on the Insert Tab on the ribbon.



  • Go to the Illustrations group and click on the Shapes icon. In the sheet, choose any shape we like and want it to be assigned as the macro.


  • Click where you want to add the shape in the sheet and the shape will automatically get inserted.

  • The shape can be resized or re-formatted accordingly to the way you want. Text can also be added in the shape.

  • Then Right-Click on the shape and a dialog box would be opened. Then click on Assign Macro.

  • After right-clicking on the shape, another dialog box of Macro would be opened.

  • In the dialog box, select the macro from the list you want to assign to your shape and click the OK button.

The work is done! Now the shape would work as a button and whenever you click on it, it will run the assigned macro.

2. Assigning a Macro to a Graphic

In Excel, there is a pool of graphics from which we can choose. There are 3-D models, Icons, pictures, shapes, and much more which can be added to the sheet as required. These graphics have a special feature i.e Macro can be assigned to them and can run macro whenever needed. 

The steps that need to be followed are:



  • Click on the Insert Tab on the ribbon.

  • From Illustrations tools, different graphics can be chosen such as shapes, icons, pictures, and 3-D models.

  • Click on any graphic and insert it into the sheet. Let’s insert a 3-D model of an insect here.

  • Then, on clicking right on the graphic, from the options, choose to assign macro.

  • A dialog box would open and select the macro you want to assign to that graphic, click OK.

Now, our graphic is ready to use. Just click on the graphic to run the assigned macro.

3. Assigning a Macro to a Control

We can also create a control button to assign a particular macro to it and when a user clicks it, the control button performs the desired set of actions. 

Let’s understand how can we implement this:

  • Go to the Developer Tab on the ribbon.

  • In the Controls group, click on the Button tool.

  • Now, click anywhere on the Excel sheet. As soon as you do this, the Assign Macro dialog box would be opened.

  • Select the macro you want to assign to that button and fill in the other options. Then click on OK.
  • After that, a rectangular button can be seen on the sheet and ready to be used.

The button which appears on the sheet has default settings, and you can’t format it like the colour, shape of the button. However, the text which appears on the button can be changed. Just a right-click on the button and a dialog box would open.

  • Click on Edit Alt Text and change the text. 

These are some objects to which a macro can be assigned. 

Attention reader! Don’t stop learning now. If you are an Excel beginner (or an intermediate) and want to learn Excel, Geeksforgeeks brings the perfect course for you to start, Diving Into Excel

My Personal Notes arrow_drop_up
Recommended Articles
Page :