简体   繁体   English

后台工作表/工作簿时动态单元格的最大最小值不更新

[英]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例如,如果您的MaxSheet1D3中并且正在监视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:笔记:

  1. stored Max value won't survive the workbook being closed and reopened.存储的最大值不会在工作簿被关闭和重新打开后继续存在。 To achieve that you'd need to store the value somewhere else, eg in an out of the way cell为了实现这一点,您需要将值存储在其他地方,例如在一个偏僻的单元格中
  2. This formula only stores one Max value.此公式仅存储一个Max 值。 If you want to use the formula >1 times in your workbook, each with its own Max, you'll need to store each Max seperately, perhaps in a Collection如果您想在工作簿中使用公式 >1 次,每个都有自己的 Max,您需要单独存储每个 Max,也许在 Collection 中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当单元格打开并选择另一个工作表时,Workbook_sheetChange 崩溃 - Workbook_sheetChange crash when cell is open and another worksheet is selected 如何在单元格中返回工作表或工作簿名称 - How to return worksheet or workbook name in cell 如何打开以工作表中的单元格命名的工作簿? - How to open a workbook named after a cell in the worksheet? Vlookup /在不同的工作表上匹配最大最小值 - Vlookup / Match max min number on different worksheet 将工作表的链接添加到同一工作簿中不同工作表中的单元格 - Adding a link to a worksheet to a cell in a different worksheet within the same workbook 创建新工作表时,从模块内部更新工作簿的内部工作表列表 - updating workbook's internal worksheet list from inside module when new worksheets are created 使用单元格引用作为工作簿和工作表的名称来激活Excel工作簿/工作表 - Activating Excel Workbook/Sheet using cell reference as name of Workbook and Worksheet 使用动态工作表名称引用另一个工作簿 - Reference another workbook with dynamic worksheet name 宏或VBA中的动态工作簿和工作表名称 - Dynamic Workbook and Worksheet name in Macro or VBA 更新行中的特定单元格时自动将行复制到另一个工作簿/工作表 - Automatically copy row to another workbook/worksheet when specific cell in the row is updated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM