Office Scripts can be shared with other users in your organization. When you share a script, you attach the script to the workbook, enabling others to view and run it.
Important: Anyone who can edit a workbook can view and run its attached scripts.
Share your script in a workbook
You can use a script's Details page to share the script in a workbook. Your scripts are stored in your OneDrive. When you share one, you create a link to it in the workbook you have open.
On the Automate tab, select the script you want to share from the gallery or the All Scripts list. Note that you can only share your own scripts. You might have access to other scripts that have been shared with you or built-in sample scripts that can’t be shared.
The Code Editor opens and displays the script you selected.
On the Code Editor's More options (...) menu, select Share.
Read the message about who can use the shared script, and select Share to proceed. In the script gallery, the script you shared now has a different icon. This indicates it has been shared in the workbook and can be run by anyone who can edit the workbook.
Shared scripts can be run by any user with write permissions to the workbook. Anything changed by the script is recorded as an edit by the person running the script, not the script’s owner.
Any updates you make to a shared script will automatically be shared with others. The script is updated when you save it. People using your script may need to reopen it if they have an old version open when you make a change.
An Office Script can only be shared within your organization. Scripts can't be shared to external users.
You can also share a script by creating a button. For more information, see Create a button to run an Office Script.
Allow a shared script to run
The first time you run a script that you don't own, the Run Permission dialog box opens. This asks whether to allow the script can view and edit the workbook. If you trust the author of the script, select Allow.
Note: The first time you run a script, the Run Permission dialog also opens whenever the script is updated by another colleague in your organization.
Introduction to Office Scripts in Excel
Office Scripts settings in Microsoft 365