开发者

Can you tell Excel not to recalculate a cell whose contents are based on a COM component?

I've got an Excel spreadsheet that uses a C# Component.

The component is an Excel Add-in and it's called via a cell's formula function.

ie

=MyCalculation(C24)

The cell C24 has a hard coded value in it, ie text that never changes and isn't based off of a formula.

However, if I instrument my C# code for the MyCalculation I find that it's called 3 different times for each cell that has that formula during the setup.

I've cached the calculation on the C# side 开发者_Go百科but I'd like to know if there anyway to tell Excel that this value never changes and it only needs to look it up once?

I assumed that if its dependencies never change then it wouldn't recalculate the value.


Excel's calculation algorithm is such that it frequently calculates formulae/functions more than once. Usually (but version dependent) after the initial calculation has determined a final calculation sequence the formulae/functions only get recalculated when they are dependent on a cell that has been dirtied (note that setting a cell to "Fred" dirties the cell even if it already contains "Fred") or is volatile.
However there are also more unusual circumstances that cause cells to be recalculated.
There is more information about this at my website.

There is no way of telling Excel never to recalculate a formula, (apart from converting the formula to a constant) except by inhibiting calculation for an entire sheet.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜