Beyond VBA: Office Scripts, Python in Excel and Copilot
Beyond VBA7 minPremium
Builds on What macros do, and how to open them safely.
A finance team in Denver is moving its workbooks to SharePoint, and half the team now opens them in the browser. Their weekly formatting macro doesn't run there, and the team lead wants to know what to use instead.
How it works
VBA runs in Excel for Windows and Excel for Mac only. Microsoft's own tool for the web is Office Scripts. In Microsoft's words, "Office Scripts in Excel let you automate your day-to-day tasks." You record them with the action recorder on the Automate tab, or write them in TypeScript, and they run in Excel for the web, Windows and Mac. They come with Microsoft 365 work and school plans and are saved in OneDrive, so Excel needs to be online to use them. Power Automate can also run them on a schedule, on workbooks in OneDrive or SharePoint.
| Row | A | B | C |
|---|---|---|---|
| 1 | Tool | Where it runs | Good for |
| 2 | VBA | Excel for Windows and Mac | Anything in desktop Excel: formatting, loops, events, your own functions, other files on your computer |
| 3 | Office Scripts | Excel for the web, Windows and Mac, with a work or school plan | Workbooks people open in the browser, and jobs Power Automate runs on a schedule |
| 4 | Python in Excel | Excel for Microsoft 365 on Windows, Mac and the web, with a paid license | Analysis and charts with Python's libraries; the code runs in Microsoft's cloud |
| 5 | Copilot in Excel | Excel with a plan that includes Copilot | Asking in plain words for a formula, a chart or a summary |
VBA is still the right tool when the workbook lives in desktop Excel, when code has to run by itself as cells change (Office Scripts don't react to events in the workbook), when cells need your own functions, or when a job opens and saves other files on your computer. Many existing workbooks also run on VBA, and they keep running in desktop Excel.
Choose Office Scripts when people open the workbook in the browser, or when the job should run from Power Automate without anyone opening Excel.
Common mistakes
- Sending a .xlsm to colleagues who use Excel for the web. They can open it, but its macros don't run there.
- Expecting a script to run offline. Office Scripts are kept in OneDrive, so Excel needs an internet connection to run them.
- Putting confidential data through Python in Excel without checking your company's rules. The Python code runs in Microsoft's cloud, not on your computer.
In short
- VBA is for desktop Excel; Office Scripts also run in Excel for the web, and Power Automate can run them on a schedule.
- Python in Excel is for analysis, and Copilot answers requests in plain words; both need the right license.
- Keep VBA for events, your own functions and work with files on your computer.
Practice
Premium3 exercises: 2 quiz questions and 1 set of steps.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in