简体   繁体   中英

How to optimize dirty cell optimization when using volatile formula in Excel (like INDIRECT() )?

This is maybe a little advanced topic.

When you press F9 or recalculate the sheets, Excel tries first to find out what cells just might had a chance to be changed, so it can skip evaluating them at all. The algorithm searches all ancestors and ancestors' ancestors to find out if value of any of them has changed. If so, it proceeds to actual evaluation.

That would be, at least, as long as there's no "INDIRECT()" formula in the path. If there is, the algorithm assumes that the value of this formula is volatile (ie it always changes) and so evaluates all the descendants.

There are more volatile formulas: RAND, AREAS, CELL, COLUMNS, INDEX, INDIRECT, NOW, OFFSET, ROWS, TODAY. Some of them obviously should be volatile (like RAND() ).

The question: is there any way of telling Excel, that a given cell that is treated volatile by Excel should in fact be kept as frozen, unless its ancestors change?


One way of resolving the problem is to write my own versions of Excel volatile functions in VBA. VBA functions are assumed not volatile.

The problem is that there is a relative high cost of VBA invocation. Another is the need of 'reinventing the wheel'. I hope there is a cheaper solution.

Not the answer you want, but... Don't use Formulas.

A user defined formula won't help either because of the limitations of what you can do inside them.

Recommend as previous comment suggested moving calculation into a pattern similiar to...
1. pull all sheet data into a 2D array.
2. perform X transformations on data.
3. push data back into an equaly sized sheet address, to the 2D array.

The answer is no. But luckily there is usually always non-volatile alternatives to using volatile functions, including CHOOSE, INDEX, and in the case of date/time funcitons you can use the volatile NOW and TODAY functions to feed a dropdown list.

For a long article with lots of links I've previously written, see https://chandoo.org/wp/2014/03/03/handle-volatile-functions-like-they-are-dynamite/ and for more on using Dropdowns to avoid volatility see my other article at http://dailydoseofexcel.com/archives/2014/02/23/data-validation-doesnt-care-about-volatility/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM