Record your actions as Office Scripts
Applies To
Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the webYou can automate your repetitive tasks with the Office Scripts. Use the Action Recorder in Excel to record your actions as scripts to replay whenever you want. The Action Recorder creates a script based on your changes to a workbook. These actions can include entering text or numbers, formatting cells, rows, or columns, creating Excel tables, and so on. The task pane displays a descriptive list of your steps as you go.
Note: You don’t need any coding experience to record and run Office Scripts. You can choose to edit your actions from the Code Editor, where you'll work with the script’s TypeScript code. Learn all about writing scripts with the Code Editor with the tutorial Record, edit, and create Office Scripts in Excel.
Get started
-
First, select the Automate tab on the ribbon. This shows your two primary options in the Scripting Tools group: Record Actions and New Script.
-
To create a new Office Script, press the Record Actions button, then start taking the steps you want to automate. For this example, we're taking a data range, converting it to an Excel table, adding a total column and total row, and finishing by formatting our values as currency.
-
When you start to record a new Office Script, a Record Actions task pane opens on the right. Here you'll see an ordered list of the actions you're taking. When you're done with all your steps, press the Stop button.
-
Once you've pressed the Stop button, the Code Editor pane displays your new script.
-
By default, Excel names your scripts "Script 1", "Script 2", and so on. However, you'll want to give your scripts meaningful names and descriptions. To give your script a new name, select the More options (...) menu and select Rename from the pop-up menu.
Apply relative mode
Relative mode helps your recorded script be more flexible. When you don’t have the exact same cell positions of the data you’re working on, you can turn on relative mode.
Default absolute mode vs
-
The exact cell locations are recorded: editing A3 will edit A3 every time the script is run.
-
Better when the cells you work with are the same cell addresses every time.
Relative mode
-
The cell locations are based off your selected cell. If you start recording the script with cell A1 selected and edit A3, the script always edits the cell that is two rows below the currently selected cell.
-
Best used when your script acts on the current cell or surrounding cells.
-
Select the drop-down menu in the Record Actions task pane.
-
Select Relative mode.
Need more help?
You can always ask an expert in the Excel Tech Community or get support in the Answers Community.
See also
Introduction to Office Scripts
Office Scripts technical documentation
Record, edit, and create Office Scripts in Excel
Troubleshooting Office Scripts