Applies To
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web

An Office Script is a convenient way to automate common tasks. Help your colleagues find and run your Office Scripts by adding a script button to a workbook. This makes it easy for anyone in the workbook to run the script.

Create a script button

This procedure creates a button in the workbook that runs the script when the button is selected. It also shares the script with anyone who can edit the workbook.

  1. Select Automate, and then select the script you want to run. If the script isn't visible in the Office Scripts Gallery, select View Scripts > Recent Scripts to open the Office Scripts task pane and choose your script.

  2. Once your script is open, scroll to the Share this script section. Enable the Associate with workbook toggle if it's disabled. Select Add button to worksheet

Scroll to Share this script and select Add button to worksheet.

Remove script buttons

This procedure stops sharing a script and removes all the buttons that run the script.

  1. Select Automate, and then select the script you want to run. If the script isn't visible in the Office Scripts Gallery, select View Scripts > Recent Scripts to open the Office Scripts task pane and choose your script.

  2. Once your script is open, scroll to the Share this script section. Disable the Associate with workbook toggle. A dialog appears to confirm your decision. Select Remove to remove all buttons that run the script. Use the checkbox to remove buttons that run this script in other workbooks.

Disable the Associate with workbook toggle and choose Remove in the dialog

Notes: 

  • If you delete a script button directly from the Excel grid, the button is removed but the script is still associated with the workbook. The Associate with workbook toggle must be disabled to stop sharing a script with a particular workbook.

  • You can't cut and paste a script button to move it within a workbook.

See also

Introduction to Office Scripts in Excel

Sharing Office Scripts in Excel for the web

Office Scripts technical documentation