Sign in with Microsoft
New to Microsoft? Create an account.

Automate your repetitive tasks with Office Scripts in Excel for the web, Windows, and Mac. Create scripts and replay them whenever you want. Share your scripts across the organization to help others make their workflows fast and consistent. Edit your scripts as your workflow changes and let the cloud update your solutions across the organization. 

Note: Before you can use Office Scripts, an administrator must enable them.

Create an Office Script

There are two ways to make a new Office Script. 

  • Record your actions with the Action Recorder (Excel on the web only). This is great when you have consistent actions that you take on your workbooks. No coding knowledge is needed to record and share Office Scripts. Get started recording with [link to the Record your actions as Office Scripts article].

  • Use the Code Editor to work with TypeScript code for advanced scripts. To learn how to start with the Action Recorder and edit scripts to better suit your needs, see the tutorial Record, edit, and create Office Scripts in Excel on the web - Office Scripts | Microsoft Learn.

Run an Office Script

  1. All the scripts you and your workbook have access to are found under Automate > All scripts. The script gallery shows the most recent scripts. 

    Script Ribbon
  2. Select the script you want to run. It will display in the Code Editor. Select the Run button to start the script. You'll see a brief notification that the script is running, which disappears when the script is complete.

    Run a script
  3. More options - Select the ellipsis (...) on the right-hand side of the Code Editor pane, to see the contextual menu. Here, you have options to:

    More Options

    • Rename the script

    • Make a Copy of the script

    • Share the script

    • Integrate the script with Power Automate by using Create Flow

    • Delete the script

Potential Errors

  • Certain actions may be fine the first time you record your script, but fail when you play it again. For instance, in the earlier example, where we formatted some sample data as a table, our code would fail if we tried to run it on the updated table, because Excel doesn't allow tables to overlap each other. At this point, the Code Editor displays an error message.

    Code Editor error message stating that the script ran with errors. Press the Logs button to learn more.

    Select the View Logs button to display a brief error explanation at the bottom of the Code Editor pane.

    Script error
  • Unsupported features - We're constantly working to add support for more features, but at this time not everything is supported. When this happens, you'll see a note in the Record Actions pane. Such actions aren’t added to the script and will be ignored.

    Racord Actions dialog indicating when certain steps could not be recorded.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See also

Record your actions as Office Scripts 

Office Scripts technical documentation

Record, edit, and create Office Scripts in Excel on the web

Troubleshooting Office Scripts

Sample scripts for Office Scripts in Excel on the web

Create a button to run an Office Script

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Office Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!

×