[英]Max Min of dynamic cell not updating when worksheet/workbook in background
How to find max and min of a dyanamic cell in Excel Hi all, with regard to the above vba code, I tried the code but the max/min cell only updates if I click on the dynamic cell and then click away. 如何在 Excel 中找到动态单元格的最大值和最小值 大家好,关于上面的 vba 代码,我尝试了代码,但只有当我点击动态单元格然后点击离开时,最大值/最小值单元格才会更新。 If the workbook is not active and is in the background while I work on other programs,the min/max cells wouldn't update.
如果工作簿未处于活动状态并且在我处理其他程序时处于后台,则最小/最大单元格不会更新。 How do I fix this?
我该如何解决? Thank you in advance.
先感谢您。
This can be achieved with a regular formula, but requires Iterative Calculation to be enabled.这可以通过常规公式实现,但需要启用迭代计算。
This is set under Options/Formulas这是在选项/公式下设置的
With this set, The Max
formula should reference the cell(s) you want to monitor, and itself.使用此设置,
Max
公式应引用您要监视的单元格及其本身。
Eg if your Max
is in D3
in Sheet1
and is monitoring B3
on Sheet2
then use例如,如果您的
Max
在Sheet1
的D3
中并且正在监视Sheet2
上的B3
,则使用
=MAX(Sheet2!B3,D3)
Note: stored Max value will survive the workbook being closed and reopened.注意:存储的最大值将在工作簿关闭和重新打开后继续存在。
Thic can be achieved with a volitile UDF
, using a Static
variable to remember the last Max value Thic 可以通过一个 volitile
UDF
来实现,使用一个Static
变量来记住最后一个 Max 值
Function MyMax(r As Range) As Variant
Application.Volatile True
Static LastMax As Variant
Dim NewMax As Variant
NewMax = Application.WorksheetFunction.Max(r)
If NewMax > LastMax Then
LastMax = NewMax
End If
MyMax = LastMax
End Function
Note:笔记:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.