ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   custom functions (https://www.excelbanter.com/excel-programming/288541-custom-functions.html)

Roel

custom functions
 
Hi,

In VBA, when I define a user function and use it in the spreadsheet, it
does not seem to update. You have to manually go into the cell and re-input
the function name to get it to update when data has changed. Can you let it
auto-update as if it was a built-in Excel function?

Thanks,

Roel



Niek Otten

custom functions
 
Hi Roel,

Probably you did not include all the arguments in the argument list of the
function definition.
If you access cells directly from within a function, not via the argument
list, Excel does not know, so it doesn't know when to recalculate.
Including "Application.Volatile" may seem to help, but there are no
guarantees that cells will be recalculated in the correct order. Even if
they seem to do so, that is no guarantee for future releases of Excel.
The only correct way is to include all input to the function in the argument
list.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

"Roel" wrote in message
...
Hi,

In VBA, when I define a user function and use it in the spreadsheet,

it
does not seem to update. You have to manually go into the cell and

re-input
the function name to get it to update when data has changed. Can you let

it
auto-update as if it was a built-in Excel function?

Thanks,

Roel





Beto[_3_]

custom functions
 
Roel wrote:

Hi,

In VBA, when I define a user function and use it in the spreadsheet, it
does not seem to update. You have to manually go into the cell and re-input
the function name to get it to update when data has changed. Can you let it
auto-update as if it was a built-in Excel function?


Add "Application.Volatile = True" in the code for your UDF.

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



All times are GMT +1. The time now is 12:10 PM.

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