Trigger spreadsheet recalculation from script

前端 未结 2 1981
萌比男神i
萌比男神i 2021-01-28 09:48

I have a script that can delete one or more named ranges. However, the sheet does not recompute either after the script finishes or after a flush command is given. The only way

相关标签:
2条回答
  • 2021-01-28 10:07

    If the action taken upon the spreadsheet has no impact on any formulas, then there will be no recalculation. Deleting a named range, for example, has no recalculation impact unless that named range is referenced in a formula. (And if that's the case, then the spreadsheet was probably broken by the deletion.)

    Spreadsheet.flush() does not force recalculation - it's only supposed to write pending changes to the spreadsheet. (And if that change doesn't affect formulas... you get the idea.)

    The net result is that you're left with the solution you describe; you need to update a cell that's involved in calculations. Replacing a formula will do. Sorry, no magic incantation for this.

    0 讨论(0)
  • 2021-01-28 10:15

    Actually, INDIRECT skips dependencies, and always recalculates on any cell change. Its good practice to avoid INDIRECT whenever possible because of this.

    That's why you can make it recalculate by just changing a cell.

    Since deleting ranges doesn't change cells, INDIRECT won't recalculate.

    0 讨论(0)
提交回复
热议问题