Lesson theory
The same task, making a header bold and writing a sum, in two languages:
' VBA
Sub Totals()
With Worksheets("Sheet1")
.Range("A1:D1").Font.Bold = True
.Range("D8").Formula = "=SUM(D2:D7)"
End With
End Sub// Office Scripts
function main(workbook: ExcelScript.Workbook) {
const sheet = workbook.getWorksheet("Sheet1");
sheet.getRange("A1:D1").getFormat().getFont().setBold(true);
sheet.getRange("D8").setFormula("=SUM(D2:D7)");
}| VBA | Office Scripts | |
|---|---|---|
| Language | Visual Basic, properties: .Value = | TypeScript, methods: getValue() / setValue() |
| Where it runs | Desktop Excel (Windows, Mac) | Excel for the web, and desktop Excel with Microsoft 365 |
| Where it's stored | Inside an .xlsm workbook | An .osts file in OneDrive; the workbook stays .xlsx |
| Automatic start | Events: Workbook_Open, Worksheet_Change | No workbook events; schedules and triggers come from Power Automate |
| User interface | UserForm, MsgBox, InputBox | No forms or dialogs; input comes from parameters or a table |
| Reach outside | Files on the computer, other Office apps | The workbook only; anything else goes through Power Automate actions |
| Indexes | Cells(1, 1) starts at one | getCell(0, 0); arrays start at zero |
How to choose. If you need forms, work with files on disk, or your company's existing macros, use VBA. If the workbook lives in the cloud, people use it in a browser, and you need scheduled runs and links to email, Teams or SharePoint, use Office Scripts with Power Automate. There is no automatic converter from VBA to Office Scripts. You rewrite the logic by hand, which is a good chance to simplify it.
The simulator doesn't run scripts. Run the code from the lesson in Excel on the web (Automate tab › Code Editor). Here you learn to read code and check yourself with formulas and a quiz.
Test yourself
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page