Run a Macro When you Click a Button in Excel

Add to Favorites
Author: | Edits: don

Make a macro run when you click a button in the worksheet in Excel.

This allows you to create a button and put it anywhere in the spreadsheet and then to have a macro run when that button is clicked.

Steps to Have a Macro Run When a Button is Clicked

  1. Create the button.  Go to the Insert tab and click the Shapes button and select the desired button shape.
    Put the button into the spreadsheet and move and size it how you want and even add text to it by clicking it and typing.
  2. Right-click the button and click Assign Macro...
  3. Choose the desired macro from the window that opens and then hit the OK button.
  4. That's it!
    Test it out:

This particular macro simply opens a small window and says "Hi!" but you can assign any macro that you want to this button.

Stop a Macro from Running When a Button is Clicked

You can easily stop the macro from being assigned to the button, meaning that nothing will happen when the button is clicked.

To do this, right-click the button > click Assign Macro > in the window that opens up, remove all of the text under where it says Macro name: and then hit the OK button.


Make sure that you have the macro already in your workbook before you try to assign it to a button.

In Excel 2007 and later you will have to save the Excel file as an Excel Macro-Enabled Workbook.

Don't forget to download the sample workbook for this tutorial so you can see this feature in action.

Downloadable Files: Excel File

Question? Ask it in our Excel Forum

Our Excel Courses

  • Skill Level: All Levels
  • |
  • 5 hours+

How to make a fully featured professional form in Excel that is unbreakable. This includes how to use the form to store, view, edit, and delete data from a data storage worksheet.

  • Skill Level: All Levels
  • |
  • 2 hours

Send Emails from Excel using VBA and Macros. This course starts from the Basics and builds up to more advanced examples with attaching workbooks, worksheets, PDF's, automatically sending emails, including a signature, error handling, increasing speed, and more.

Similar Content on TeachExcel
Run a Macro when a User Does Something in the Worksheet in Excel
Tutorial: How to run a macro when a user does something in the worksheet, everything from selecting ...
Run a Macro when a User Does Something in the Workbook in Excel
Tutorial: How to run a macro when a user does something within the Workbook in Excel, such as openi...
Automatically Run a Macro so Many Seconds, Minutes, or Hours After an Excel Workbook has been Opened
Macro: Run a macro after a certain amount of time has passed since the Excel workbook was ope...
Excel Data Validation - Limit What a User Can Enter into a Cell
Tutorial: Data Validation is a tool in Excel that you can use to limit what a user can enter into a...
Stop Excel Events from Triggering when Running a Macro
Tutorial: Create a macro that will run without triggering events, such as the Change event, or Activ...
Disable Calculation of Cells when Running a Macro in Excel
Tutorial: How to stop formulas and functions from updating in Excel when running a macro. This can s...