[英]Using max/min functions to remember highs/lows in dynamic data in Excel
I have dynamic data shown in Excel.我在 Excel 中显示了动态数据。 The data itself is pulled using COM from external application, and it is basically number changing over time (for example, outside temperature which is received from weather website).
数据本身是使用 COM 从外部应用程序中提取的,它基本上是随时间变化的数字(例如,从天气网站接收的外部温度)。
Is there some convenient way to store MIN/MAX() of value observed during some period without use of VBA and macroses?是否有一些方便的方法可以在不使用 VBA 和宏的情况下存储在某个时期观察到的 MIN/MAX() 值? Using simple formula in
max_cell
like =IF(data_cell>max_cell, data_cell, max_cell)
gives circular reference.在
max_cell
使用简单的公式,如=IF(data_cell>max_cell, data_cell, max_cell)
给出循环引用。
If you turn Iteration on then the circular reference will work ok on a continuous basis如果您打开迭代,则循环引用将持续正常工作
And rather than an IF you can just use in A1 (where A1 is max_cell, A2 data_cell)而不是 IF 你可以只在 A1 中使用(其中 A1 是 max_cell,A2 data_cell)
=MAX(A1,A2)
Enabling Iteration启用迭代
I appreciate you asked for a non VBA solution but I will offer one as it is quite trivial to implement and understand.感谢您要求提供非 VBA 解决方案,但我会提供一个,因为实施和理解非常简单。 I'll leave it up to you whether you want to use it or not.
不管你想不想用,我都会留给你的。
Suppose your data is organised as follows in Sheet1
of your workbook:假设您的数据在工作簿的
Sheet1
中组织如下:
A B C
1 Temp Max Min
2 25 32 14
The following code will update Max
and Min
whenever Temp
changes:每当
Temp
更改时,以下代码将更新Max
和Min
:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim temp As Range, max As Range, min As Range
Set temp = Range("A2") //Change for your specific set-up
Set max = Range("B2") //Change for your specific set-up
Set min = Range("C2") //Change for your specific set-up
If Not Intersect(temp, Target) Is Nothing Then
max = WorksheetFunction.max(Target, max)
min = WorksheetFunction.min(Target, min)
End If
End Sub
For clarity, to add this code from worksheet:为清楚起见,从工作表中添加此代码:
Worksheet
in left hand drop down menu and then Change
in right hand drop downWorksheet
,然后在右侧下拉菜单中选择Change
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.