Related topics
×
Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

You 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

  1. First, select the Automate tab on the ribbon. This shows your two primary options in the Scripting Tools group: Record Actions and New Script.

           Scripting Tools

  2. 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. 

  3. 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.

  4. Once you've pressed the Stop button, the Code Editor pane displays your new script. 

  5. 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.

  1. Select the drop-down menu in the Record Actions task pane.

  2. Select Relative mode.

The option selector for Record Actions showing options of 'Relative mode' and 'Absolute 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

Sample scripts for Office Scripts in Excel

Create a button to run an Office Script

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×