开发者

is there a documented excel cell update order?

I have a spreadsheet that has a small number of inputs, which drive a large number of intermediate calculations, which in turn drive a small number of expensive calculations that depend on many of the intermediate values. Some of the calculations use UDFs which return both single return values and arrays, while others are regula开发者_StackOverflow中文版r formulas in the cell itself.

I am curious if there is a known model to describe the update order of cells in Excel.

For instance, it could be changing input A1, which calculations B1, B2, B3 depend on, and calculation C1 depends on B1, B2, and B3... will C1 be updated three separate times as the intermediate values each update, or will B1, B2, and B3 update first, and C1 updates only once?


There is documentation about the algorithms Excel uses to find calculation sequences here
http://www.decisionmodels.com/calcsecretsc.htm
http://msdn.microsoft.com/en-us/library/aa140058%28office.10%29.aspx

But the bottom line is that since the calculation chain is dynamically determined and starts from the previous calculation chain sequence cells may be calculated more than once on one occasion and not on a subsequent recalc.
If you know the structure of your calculation dependencies you can control things to a certain extent by using Range.Calculate and Sheet.calculate.


Excel now uses Multi-Threaded Calculation that makes the whole thing difficult to predict, excepting those directed childs in the dependency tree. See the link.

HTH!


With respect to your more specific question "C1 = C1(B1,B2,B3) and B1 = B1(A1), B2 = B2(A1), B3 = B3(A1) the calculation order will be

1) A1 2) B1, B2, B3 (in arbitrary order) 3) C1

and C1 will be calculated only once.

I make that claim not from any Excel documentation but from my experience with Excel and my work on a Java object handler for spreadsheets (see this paper). From what I observed, Excel does not make unnecessary calls to functions in cell.

If the dependency tree of a sheet has several "leaves" which could "ignite" the calculation, then it is not determined where Excel starts. If you open a sheet and the whole sheet is re-calculated, the calculation order of "independent" cells is hard to predict. The cache of values stored with the sheet may have an effect on the recalculation. (What I saw is: the first cell excel touches is the last cell changed before the sheet has been saved).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜