Hi
Wazooli said:
I have inserted this code in my book.xlt, so it is always present. I know
nothing about VBA, so all this talk of volatility, etc... is completely not
understood by me. Is this code, as written, acceptable to be present in
large spreadhsheets? Will its presence have deleterious effects on
performance?
When the UDF is volatile (contains code 'Application.Volatile' at start),
it's recalculated whenever any cell entry is changed, regardless there is a
need for it or not.
When the UDF isn't volatile, it's recalculated only, when it's argument(s)
do change. So my function posted here at start recalculates only, when the
value in cell (A1 in my example) the function refers to is changed. Ola's
improvement forces recalculation for particular cell, whenever any cell is
changed (because time always changes) - i.e. the function behaves as
volatile for this particular cell.
You can use this function, as any other UDF, in any workbook. It doesn't
matter, is the workbook large or not, but it matters in how much cells you
use it. This function MUST be always volatile (through code, or through
Ola's trick), and when you use it in too many cells, then the workbook will
be slowed down considerably. I don't see any other negative effects though.
Arvi Laanemets