VBA vs Python in Excel: which automation tool fits?

Microsoft now gives you four ways to hand Excel work over to code: VBA macros, Python in Excel, Office Scripts and Power Automate. The names overlap, but they solve different problems and run in different places. Here is a straight comparison, including what each one cannot do.

In short: VBA drives desktop Excel on Windows and Mac, from formatting to files, with no extra subscription. Python in Excel runs analysis inside a cell, in Microsoft's cloud, and only sees the data you pass to it, so it is not a macro replacement. Office Scripts are TypeScript scripts for Excel on the web (and Windows and Mac) on Microsoft 365 business or education plans. Power Automate builds workflows across apps and can run Office Scripts on a schedule.

VBA: macros in desktop Excel

VBA (Visual Basic for Applications) is built into the desktop versions of Excel for Windows and Mac, and Microsoft notes that it needs no special licensing. A macro has the same security clearance as Excel, so it can fill and format cells, add sheets, open and save workbooks, read files and work with other programs on your machine. Event procedures let it react when someone edits a cell (see events). Microsoft also states that VBA covers more of Excel than Office Scripts do, especially desktop features.

The limits: macros do not run in Excel for the web or on iPad. There is no Power Automate connector for VBA, so a person with Excel open starts the macro. And according to Microsoft, VBA has no convenient way to call out to the internet. For the Mac side of things, see VBA on Mac.

Python in Excel: analysis in a cell

You type =PY into a cell and write Python. The code does not run on your computer: it runs in the Microsoft Cloud with a set of libraries provided by Anaconda. You need a qualifying Microsoft 365 subscription and an internet connection. Python in Excel is available in Excel for Windows, Excel for Mac and Excel on the web, but not on iPad, iPhone or Android.

The key point for this comparison: your code gets its data through the xl() function, meaning only the ranges you reference. Microsoft states that it has no access to other properties of the workbook, no network access and no access to your computer. That makes Python in Excel a tool for analysis. It cannot stand in for a macro that adds sheets, formats a report or saves files.

Python also exists as a standalone language on your own machine, where scripts can read and write Excel files from the outside. That is a separate programming project rather than something inside Excel, so it is left out here.

Office Scripts: automation for Excel on the web

Office Scripts are written in TypeScript, a superset of JavaScript, in a code editor inside Excel. Much like the macro recorder, the action recorder captures your steps as a script that you can then edit. Scripts can sit behind a button in the workbook and be shared with colleagues.

Microsoft lists these requirements: Excel on the web, Excel for Windows (version 2210 or later) or Excel for Mac, OneDrive for Business, and a Microsoft 365 business or education license. On personal and family plans, Office Scripts are only in preview through the Microsoft 365 Insider program. A script can reach the workbook but not the computer, cannot load third-party libraries and does not respond to events such as a changed cell. It runs when someone starts it or when a Power Automate flow calls it. You find it on the Automate tab.

Power Automate: workflows across apps

Power Automate is a Microsoft service for building automated workflows between apps and services out of ready-made actions rather than code. For Excel it offers two routes:

  • Cloud flows can run Office Scripts on a schedule or when, say, an email arrives, without anyone opening Excel. Using Office Scripts this way requires a Microsoft 365 business license.
  • Power Automate for desktop is a Windows application that automates programs on your PC. Its Excel actions include Launch Excel and Run Excel macro, so an existing VBA macro can become one step of a larger flow.

Side by side

VBAPython in ExcelOffice ScriptsPower Automate
LanguageVBAPythonTypeScriptready-made actions
Where it runsin Excel on your computerMicrosoft Cloudin Excel, or from Power Automatecloud service; desktop flows in a Windows app
Excel for Windows and Macyesyesyes (Windows version 2210+)desktop flows on Windows only
Excel for the webnoyesyescloud flows work with Office Scripts
iPad and iPhonenonononot applicable
What you needdesktop Excel, no extra licensequalifying Microsoft 365 plan, internetMicrosoft 365 business or education, OneDrive for Businessbusiness license to run Office Scripts
What the code can reachworkbook, files, other programsonly the data passed inthe workbook onlymany apps and services
Good forcleaning lists, building reports, combining sheetsstatistics and analysis with Python librariesrepeatable steps in shared workbooksscheduled workflows across several apps

Which one should you learn?

  • You use Excel on your own PC or Mac and want to stop doing the same steps every week: learn VBA. It needs no extra plan and, by Microsoft's own account, covers more of Excel than Office Scripts. Macro examples gives you an idea of what that looks like.
  • You do statistical analysis and have a qualifying Microsoft 365 plan: Python in Excel sits nicely next to your formulas. If the data lives in a database, start with the SQL course instead.
  • Your team works in Excel for the web and Teams and wants things to run unattended: Office Scripts with Power Automate.

These are not either/or choices. Variables, loops, conditions and thinking in ranges carry over from one language to the next. VBA is a practical first step because you can use it on your own workbooks straight away.

Writing Excel macros with ChatGPT and other AI tools

An AI chat tool will produce a macro in seconds, and for routine jobs the result is often usable. The trouble is that wrong code looks just as convincing as right code: a hard-coded last row, the wrong sheet, a function that does not exist in VBA, or a delete with no confirmation. You cannot undo a macro with Ctrl+Z. So you still need to read the code, understand it and test it on a copy before it touches real data. That is exactly the skill the course trains: every exercise also checks your macro against data you cannot see. One more habit worth keeping: do not paste confidential company data into a chat to get a macro; a few made-up sample rows are enough.

FAQ

Does Python in Excel replace VBA?

No. Python in Excel works with the data you pass in through xl() and returns a result to the cell. Microsoft says it has no access to other workbook properties or to your computer. Formatting, adding sheets, saving files and reacting to edits remain VBA territory.

Can I run VBA macros in Excel for the web?

No. Excel for the web cannot create, run or edit VBA macros, although it keeps them in the workbook. Office Scripts are the automation tool for Excel on the web.

Can Power Automate run an Excel macro?

Not from a cloud flow, since there is no connector for VBA. Power Automate for desktop, the Windows application, does have a Run Excel macro action that runs a macro in a workbook it opened with Launch Excel.

Do I need Excel to learn here?

No. The VBA exercises run in your browser, and your code runs on our server in a re-creation of VBA. The online VBA editor is there for free experiments. For your own macros at work you will later need Excel for Windows or Mac.

Up next: start with VBA

The first lesson shows how a macro is put together and how to add it to Excel. The VBA course then takes you level by level to a finished monthly report.

VBA basics

Write to us

Choose language

Select your preferred language