How to Assign Macro to Button in Excel (2 Easy Methods)

While working in Microsoft Excel sometimes we need to do a task again and again inside a workbook. For that, you can simply assign a macro to a button so that you don’t have to repeat the same procedure for every sheet. Just click the button and your work will be done as assigned. In this article, we shall learn how to assign a Macro to a button in Excel. Let’s start.


Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


2 Simple Methods to Assign Macro to Button in Excel

In the following, I have shared 2 simple and easy methods to assign a macro to a button in excel.

Suppose we have a dataset of some Student Names and their Exam Results in a worksheet. Now we will assign a macro to a button in excel.


1. Use Form Control Feature to Assign Macro to Button in Excel

After you have recorded and tested a macro, you may want to assign your macro to a button placed on a worksheet. Simply use the developer feature to do so-

Steps:

  • First, press the “Button” icon from the “Insert” option to create a button inside your worksheet.

Use Developer Feature to Assign a Macro to a Button in Excel

  • Secondly, draw a button anywhere on your worksheet.

  • After drawing the button a new window will appear asking to assign a macro for the created button.
  • Gently, choose your macro and select “This workbook” from the drop-down list below.
  • Press OK.

Use Developer Feature to Assign a Macro to a Button in Excel

  • Therefore, selecting cells click the button icon to get the output.

Use Developer Feature to Assign a Macro to a Button in Excel

  • Finally, you will see the selected cells are colored according to the macro. This way you can create and assign a macro to a button in excel.

Use Developer Feature to Assign a Macro to a Button in Excel

Read More: 22 Macro Examples in Excel VBA


Similar Readings


2. Insert Shape to Assign a Macro in Excel

If you want you can also insert your desired shape and then assign a macro of your choice. To do so-

Step 1:

  • Starting with, let’s create a shape from the “Insert” option. Here I have selected the “Oval” shape to draw inside the spreadsheet.

Insert Shape to Assign a Macro in Excel

  • Hence, selecting draw the shape at any position on your worksheet.

  • In the same fashion, let’s assign a macro for the drawn shape by right-clicking the mouse button and choosing “Assign Macro“.

Insert Shape to Assign a Macro in Excel

  • Now, choose your macro, and then from the drop-down list select “This Workbook“.
  • Hit the OK button to continue.

Step 2:

  • In addition, you can change the texts inside the shape from the “Edit Text” option.

  • Then, select any cell from the worksheet and press the “Shape” which is assigned with the macro.

Insert Shape to Assign a Macro in Excel

  • In conclusion, we will get the output as assigned in the macro code. This is the simplest way to assign a macro in excel.

Insert Shape to Assign a Macro in Excel

Read More: How to Edit Macros in Excel (2 Methods)


Things to Remember

  • While working in Microsoft Excel, you might not find the “Developer” option in the top ribbon of the workbook. In that situation just got to File > Options > Customize Ribbon. From the dialog box checkmark the “Developer” feature and press OK to get it.

Conclusion

In this article, I have tried to cover all the methods to clean data in excel. Take a tour of the practice workbook and download the file to practice by yourself. I hope you find it helpful. Please inform us in the comment section about your experience. We, the Exceldemy team, are always responsive to your queries. Stay tuned and keep learning.


Further Readings

Khan Muhammad Kawser

Khan Muhammad Kawser

Hello! Welcome to my Excel blog! It took me some time to be a fan of Excel. But now I am a die-hard fan of MS Excel. I learn new ways of doing things with Excel and share them here. Not only a how-to guide on Excel, but you will get also topics on Finance, Statistics, Data Analysis, and BI. Stay tuned! You can check out my courses at Udemy: udemy.com/user/exceldemy/

We will be happy to hear your thoughts

Leave a reply

5 Excel Hacks You Never Knew

Genius tips to help you unlock Excel's hidden features

FREE EMAIL BONUS

ExcelDemy
Logo