当工作表中的任何单元格更改时,Excel VBA重新运行公式(更新) [英] Excel VBA Re-run formulas (update) when any cell in sheet changes
问题描述
我已经在VBA中编写了一个Function以基于某些单元格的值返回某个值.我在某个单元格的公式中执行/运行此功能
I've written a Function in VBA to return a certain value based on certain cells' values. I execute/run this function in a formula on a certain cell
=MyFunction()
我的问题是,如果更改了该函数(在VBA中)使用的单元格,则具有上述公式的单元格不会自动更新.
My problem is, the cells which have the above formula don't automatically update if the cells used in the function (in VBA) are changed.
如果更改了所使用的某些单元格,如何重新运行或更新或重新执行上述公式?
How can I re-run or update or re-execute the above formula if the certain cells that are used are changed?
推荐答案
您必须重新编码 UDF ,以实现所需的波动性.假设您要更改 A1 或 B1 或 C1 ,则UDF重新计算,然后使用:
You must recode your UDF to achieve the desired volatility. Say you want the UDF to re-calculate if A1 or B1 or C1 are changed, then use:
=MyFunction(A1,B1,C1)
使用自变量获得所需的波动性.
Using arguments gets the required volatility.
这篇关于当工作表中的任何单元格更改时,Excel VBA重新运行公式(更新)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!