Use Worksheet Change Events Instead of Office Scripts in Excel for the Web
Question details
The user wants to detect worksheet changes and run code 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.
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.
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.
Create or open an Excel Add-in project that uses the Excel JavaScript API, then open the target workbook in Excel for the Web.
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.
Load the add-in in the workbook, start it, and edit a cell on the monitored worksheet to verify that the handler runs.

Run an Office Script on a Schedule with Power Automate
Use a scheduled flow when periodic processing is sufficient and an immediate worksheet change event is not required.
Use a Worksheet Change Event in Desktop Excel with VBA
Use VBA when the workbook can be opened in desktop Excel and macro-based event handling is acceptable.
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.

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.




