No — Excel Script is not the same as VBA. Excel Script is a newer automation language built on TypeScript that runs in Excel on the web (and in newer desktop builds), while VBA is the older Visual Basic for Applications language that lives inside the classic Windows and Mac desktop program. They solve similar problems — automating cells, formatting, and data cleanup — but they use different languages, different security models, different storage, and they cannot run each other's code without a rewrite.

The confusion is understandable: both are called "macros" by many users, both appear in the Automate tab area of modern Excel, and both can be recorded rather than hand-coded. This article explains exactly where the two systems diverge, what each one can do that the other cannot, and how to choose for a given job.

A quick background on both systems

VBA has been part of Excel since the mid-1990s. It is an event-driven version of BASIC, stored inside the workbook itself in a binary project file, and edited in the Visual Basic Editor, which you open with Alt+F11 on Windows. Because it lives in the file, a macro-enabled workbook (.xlsm) travels with its code: hand someone the file and the macros go too.

Excel Script is much newer and part of the Office Scripts platform. It uses TypeScript, a typed superset of JavaScript, and is stored separately from the workbook — in your OneDrive or SharePoint account rather than embedded in the .xlsx file. That storage difference turns out to be the single most important practical distinction, because it determines where the code can run and how it gets shared.

The language and the programming model

The two are not dialects of each other. Nothing you write in VBA can be pasted into an Excel Script and expected to work, and vice versa. Key differences:

  • Language: VBA is BASIC-like with line numbers optional, Sub and Function blocks, and no strong typing by default. Excel Script is TypeScript: curly braces, semicolons, async/await, and type declarations that the editor checks as you type.
  • Object model: VBA drives the Range, Worksheet and Workbook objects through a COM interface. Excel Script uses the Office JavaScript API, where most calls return promises — so a script reads your data with await before manipulating it.
  • Recording: both have a recorder. The VBA recorder produces VBA; the Automate tab's Record Actions button produces an Excel Script.
  • Error handling: VBA uses On Error statements; TypeScript uses try/catch blocks.

Because TypeScript is a mainstream web language, someone who already writes JavaScript will find Excel Script familiar almost immediately, whereas VBA's quirks (untyped variables, the Range("A1").Select habit, implicit conversions) take longer to master from scratch.

Where each one runs

This is where the choice usually gets made for you.

  • VBA runs only in the desktop Excel application on Windows and Mac. It does not run in Excel for the web, on a phone, or on a tablet. It also needs the workbook to be macro-enabled, and many organizations block VBA macros by policy.
  • Excel Script runs in Excel on the web and in supported desktop builds, and it can be triggered from Power Automate without Excel being open at all. That makes it the only option for scheduled, unattended automation of a workbook sitting in OneDrive or SharePoint.

A practical example: if you want a script that tidies a spreadsheet every morning at 6 a.m. while nobody is at their desk, VBA cannot do it — the desktop app would have to be open and running. An Excel Script can be scheduled through a Power Automate flow instead. Conversely, if you need automation in a workbook that lives on a network share and gets emailed around as an .xlsm, VBA is the straightforward path.

Feature comparison at a glance

  • UserForms and custom dialogs: VBA has them; Excel Script does not. There is no built-in way to pop up a custom form from a script.
  • ActiveX controls and COM add-ins: VBA can call into other Office apps and Windows components. Excel Script is sandboxed to the Excel workbook and cannot touch the local file system or other applications.
  • Cross-workbook operations: VBA can open other workbooks and drive Word, Outlook or Access. Excel Script works on the workbook it is attached to and, through Power Automate, can be chained with other services — but not by talking to a local Outlook client.
  • Event handlers: VBA can respond to events like Worksheet_Change or Workbook_Open. Excel Script does not run on those triggers; it is run manually, by a button, or by an external flow.
  • Sharing: VBA code travels inside the file. Excel Script code is shared by granting access to the script in your OneDrive, or by sharing the workbook it is attached to, depending on how the script is authored.

How to choose for a real task

Work through these questions in order; the first one that applies usually settles it.

  1. Does the automation need to run while nobody has Excel open? Choose Excel Script with Power Automate.
  2. Does it need to run in Excel for the web, on a Mac without the full desktop build, or on a locked-down machine where macros are disabled? Choose Excel Script.
  3. Does it need custom dialog boxes, ActiveX controls, or to drive Outlook, Word or the local file system? Choose VBA.
  4. Must the code travel inside the workbook file itself, for example to an external recipient? Choose VBA, accepting that many recipients will be blocked from running it.
  5. Will non-technical colleagues maintain it? Excel Script's separate storage and browser-based editor make version control and sharing cleaner, but VBA's recorder and huge body of online examples make it easier to find ready-made answers.

In many organizations the honest answer is "both": VBA for legacy workbooks with embedded macros, Excel Script for anything new that touches cloud-stored files.

Common problems and gotchas

People migrating between the two hit predictable walls.

  • "My Excel Script won't run in the desktop app." Excel Scripts require a supported Microsoft 365 build and are typically only available when the file is stored in OneDrive or SharePoint. A local file saved to a desktop folder may not offer the option. Labels in the Automate tab can differ slightly by version, device and region.
  • "The script says it can't find the range." Because calls are asynchronous, code written without await will often operate on an empty object. Add the await keyword to every worksheet and range call.
  • "Macros are blocked by my IT department." That is a policy setting, not a bug, and it is common. Excel Script is often the approved alternative — but check with IT first, since script sharing is governed by your tenant's settings too.
  • "VBA recorded code is slow." Recorder output typically selects cells before acting on them. Replacing selections with direct range references speeds it up dramatically.

Safety matters in both cases: only run macros and scripts from sources you trust, since both can modify or delete data in your workbook. Excel Script runs in a sandbox with no access to your local machine, which reduces some risk, but it can still overwrite cells. Always keep a copy of important workbooks before running unfamiliar code.

Frequently Asked Questions

Can I convert a VBA macro into an Excel Script automatically?

No. There is no automatic converter. The languages and object models are different, so a VBA macro has to be rewritten by hand in TypeScript. The Excel Script recorder can help you capture the equivalent actions, but loops, conditional logic and error handling must be re-authored.

Will VBA be removed from Excel?

VBA remains supported in the desktop versions of Excel and is not being switched off. Excel Script is an addition for cloud and cross-platform scenarios, not a replacement that removes existing VBA capability.

Do Excel Scripts work in Excel for the web?

Yes — that is one of their main advantages over VBA. Scripts can be run from the Automate tab in the browser and also triggered from Power Automate.

Which is easier to learn?

If you already know JavaScript or TypeScript, Excel Script is easier. If you have no programming background, the VBA recorder plus the sheer volume of VBA examples online often makes VBA a gentler start, though neither language is hard to record your way into.

Do Excel Scripts run on a phone or tablet?

Running and editing scripts is not available in the mobile Excel apps. You can run them in Excel on the web or a supported desktop build; triggered flows run in the cloud regardless of device.

Does an Excel Script travel with the workbook if I email the file?

Not the way VBA does. Scripts are stored in your OneDrive or SharePoint, so a recipient without access to that location will not get the code. If the code must go with the file, VBA is the appropriate choice.