ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autocalculate to include my function (https://www.excelbanter.com/excel-programming/343792-autocalculate-include-my-function.html)

John F[_2_]

autocalculate to include my function
 
I have created a small function in module1. The function works correctly
when entered in the worksheet but does not auto recalculate when some of the
data it uses is updated.

Can I force the recalculation to include this function?

John.

Niek Otten

autocalculate to include my function
 
Hi John,

Please post the code of the function and the formula with which you call it.
Probably the reason for not recalculating is that you access some cells
directly from within the function.
All input to a function should be via the argument list; otherwise Excel is
not aware of the need for recalculation.
A workaround is to include "Application.Volatile" in your function.
However, that may slow down recalculation of your workbook and it is not
guaranteed that it will be recalculated correctly in future versions of
Excel.
The only *correct* way is to include all input in the argument list.

--
Kind regards,

Niek Otten

"John F" wrote in message
...
I have created a small function in module1. The function works correctly
when entered in the worksheet but does not auto recalculate when some of
the
data it uses is updated.

Can I force the recalculation to include this function?

John.




Tom Ogilvy

autocalculate to include my function
 
Public Function myFunction()
Application.Volatile

End Function

so using applicaton.Volatile will cause it to be recalced on every
calculation. The alternative is to make the dependent cells part of the
argument list for the function. This is what excel used to determine which
cells it is dependent on.

--
Regards,
Tom Ogilvy
"John F" wrote in message
...
I have created a small function in module1. The function works correctly
when entered in the worksheet but does not auto recalculate when some of

the
data it uses is updated.

Can I force the recalculation to include this function?

John.





All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com