-
Notifications
You must be signed in to change notification settings - Fork 270
[Excel] Update low engagement articles #5374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c12406e
[Excel] Update data validation article
alison-mk e8a1293
Update delay cell edit article
alison-mk d0af5a1
Update special cells article
alison-mk 9d29342
Update performance article
alison-mk c1199c6
Add changes for multiple ranges article
alison-mk 258829c
Add large range updates
alison-mk a66bb0d
Add precedents article changes
alison-mk d8053d5
Add precedents article changes
alison-mk a4b4076
Update docs/excel/excel-add-ins-ranges-large.md
alison-mk 6c20f28
Minor tweaks
alison-mk a79229c
Merge branch 'alison-mk-fhl-low-engagement-2' of https://github.com/O…
alison-mk 8b3ec4f
Update docs/excel/excel-add-ins-ranges-large.md
alison-mk 038d46d
Apply suggestions from code review
alison-mk dcccd1c
Incorporate code review feedback
alison-mk 8012d1c
Add line about Range.getSpecialCells to create RangeAreas
alison-mk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
--- | ||
title: Delay execution while cell is being edited | ||
description: Learn how to delay the execution of the Excel.run function when a cell is being edited. | ||
ms.date: 02/16/2022 | ||
description: Defer an Excel.run batch until the user leaves cell edit mode instead of failing with an error. | ||
ms.date: 09/19/2025 | ||
ms.localizationpriority: medium | ||
--- | ||
|
||
|
||
# Delay execution while cell is being edited | ||
|
||
`Excel.run` has an overload that takes in a [Excel.RunOptions](/javascript/api/excel/excel.runoptions) object. This contains a set of properties that affect platform behavior when the function runs. The following property is currently supported. | ||
When a user is actively editing a cell, some add-in operations may fail immediately. Use the `delayForCellEdit` option to queue the batch until the user exits cell edit mode instead of throwing an error. | ||
|
||
`Excel.run` has an overload that takes an [Excel.RunOptions](/javascript/api/excel/excel.runoptions) object. It supports the following property relevant to this scenario. | ||
|
||
- `delayForCellEdit`: When `true`, Excel queues the batch until the user exits cell edit mode. When `false`, the batch fails immediately if the user is editing. The default value is `false`. | ||
|
||
## Behavior comparison | ||
|
||
| User editing? | `delayForCellEdit = false` (default) | `delayForCellEdit = true` | | ||
|---------------|------------------------------------|--------------------------| | ||
| No | Batch runs immediately | Batch runs immediately | | ||
| Yes | Batch fails (`InvalidOperation` error) | Batch waits; then runs after edit is committed or canceled | | ||
|
||
- `delayForCellEdit`: Determines whether Excel delays the batch request until the user exits cell edit mode. When `true`, the batch request is delayed and runs when the user exits cell edit mode. When `false`, the batch request automatically fails if the user is in cell edit mode (causing an error to reach the user). The default behavior with no `delayForCellEdit` property specified is equivalent to when it is `false`. | ||
## Example | ||
|
||
```js | ||
await Excel.run({ delayForCellEdit: true }, async (context) => { ... }); | ||
await Excel.run({ delayForCellEdit: true }, async (context) => { | ||
const sheet = context.workbook.worksheets.getActiveWorksheet(); | ||
const range = sheet.getRange("A1"); | ||
range.values = [["Updated while user was editing elsewhere"]]; | ||
await context.sync(); | ||
}); | ||
``` | ||
|
||
## Guidance | ||
|
||
- Use `delayForCellEdit` only when user-initiated commands may overlap active cell editing, such as with a ribbon button that triggers a bulk update. | ||
- Consider showing a status indicator in your add-in if queued work may be lengthy. | ||
- Avoid chaining multiple long-running delayed batches. This creates a perceived lag for your users. | ||
|
||
## Next steps | ||
|
||
Explore related user-state strategies in [Events](excel-add-ins-events.md), such as reacting to selection changes, and combine with `delayForCellEdit` to improve your add-in's robustness. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.