can office scripts run automatically whenever a cell is edited?

SURGEON H 0 Reputation points
2026-11-23T12:19:40.4+00:00

I'm using a shared Excel workbook where my team updates employee information in a worksheet. I'd like to automatically check the entries whenever someone changes a cell, without having to run the Office Script manually. I know VBA has the Worksheet_Change event, but I can't find something similar in Office Scripts. Is there another way to do this?

Microsoft 365 and Office | Excel | For business | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Michelle Nguyen 3,125 Reputation points Independent Advisor
    2026-11-23T12:46:24.61+00:00

    Hi @SURGEON H

    I'm just a fellow community user, so please treat this as general guidance.

    As far as I know, Office Scripts don't have an equivalent of VBA's Worksheet_Change event. A script runs only when someone runs it manually (or through a button), or when Power Automate calls it, so it can't run automatically each time a cell is edited.

    Depending on what kind of checks you need, here are some alternatives:

    1. Data Validation: if the checks are about allowed values, formats, dates, number ranges or text length, Excel's built-in Data Validation (Data > Data Validation) checks entries instantly as people type, without any script. It also works in Excel for the web and with co-authoring.
    2. Conditional Formatting: you can highlight invalid or missing entries with formula-based rules, so your team can see problems right away.
    3. Power Automate on a schedule: if the checks are more complex, you can create a scheduled flow that runs your Office Script (for example every hour) and flags or reports invalid entries. This isn't real time, and the Run script action has a daily limit of 1,600 calls per user, so choose the schedule carefully.
    4. Excel add-in: if you really need code to run on every change, the Excel JavaScript API used by Office Add-ins supports an onChanged event for worksheets and tables. However, this requires building and deploying an add-in, which is more work than an Office Script.

    Could you share what kind of checks you want to run on the employee information (for example required fields, duplicates, or specific formats)? That would help suggest the simplest option.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.