VBA & Macro Problems

Use Worksheet Change Events Instead of Office Scripts in Excel for the Web

Phi Hung VoPhi Hung Vo Nov 18, 2026 868 views

Question details

The user wants to detect worksheet changes and run code in Excel for the Web.

Do Office Scripts Support Worksheet Change Events in Excel for the Web?
Product
Microsoft Excel for the Web and Office Scripts
Device & OS
not provided
Scenario
A workbook needs event-driven behavior when a worksheet changes.
Observed behavior
The Office Scripts ExcelScript API does not expose worksheet change event listeners such as worksheet.onChange.add.
Before you start

Decide whether the action must respond immediately to a worksheet change or can run on a schedule. Check the current Microsoft ExcelScript API documentation for changes to available features.

Solution 1Recommended

Use an Excel Add-in to Listen for Worksheet Changes

Use the Excel JavaScript API when you need an event handler for changes while an add-in is running.

Excel Add-ins use a different API from Office Scripts. Their worksheet onChanged event can register a handler, but it is not a persistent background listener after the add-in is closed.

1
Create an Excel Add-in

Create or open an Excel Add-in project that uses the Excel JavaScript API, then open the target workbook in Excel for the Web.

2
Register the handler

In the add-in code, use Excel.run to get a worksheet, call worksheet.onChanged.add(handler), and await context.sync() to register the event handler.

3
Run and test the add-in

Load the add-in in the workbook, start it, and edit a cell on the monitored worksheet to verify that the handler runs.

Use an Excel Add-in to Listen for Worksheet Changes
Keep the add-in running: The handler is registered for the add-in session; do not rely on it to monitor changes while the add-in is closed.
Free Microsoft Office alternative

Work with Excel Spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and compatibility with common Excel formats, making it easy to move everyday workbook editing to WPS. It does not add worksheet event listeners to Microsoft Office Scripts.

Open and edit spreadsheets in a familiar interfaceCompatible with common Microsoft Excel formats, including XLSX and XLSFree and lightweight for everyday spreadsheet workMove routine workbook editing to WPS without relying on Office Scripts
microsoft office alternative - wps office

Frequently Asked Questions

Can an Office Script use worksheet.onChanged.add?

No. Office Scripts use the ExcelScript API, which does not provide worksheet event listeners. The worksheet onChanged event belongs to the Excel JavaScript API used by Office Add-ins.

Will an Excel Add-in listen for changes after it closes?

No. An event handler is registered for the add-in session, so the add-in must be running to handle the events.

Can Power Automate run a script after every cell edit?

A scheduled Power Automate flow can run an Office Script periodically, but it is not an immediate listener for every cell edit. In Power Automate, use Create > Scheduled cloud flow and add the Excel Online (Business) Run script action.

Can I use Worksheet_Change in Excel for the Web?

No. Worksheet_Change is a VBA event and VBA macros do not run in Excel for the Web. Open the workbook in desktop Excel and add the procedure in the worksheet's VBA code module.