excel - 从动态单元格中获取最高和最低值
问题描述
我一直试图从单元格 AO1 到 AP2 的单元格 R1 和 R2 中获取最高和最低值。我能够在 AO1 和 AO2 中获得最高值,但它没有在 AP1 和 AP2 中记录最低值。一旦在 AP1 和 AP2 中输入等效数字(R1 和 R2 的值),最低值开始记录,当尝试调试时,R1 和 R2 中的值显示,但 AP1 和 AP2 为“空”。
有人可以帮忙吗。这就是我到目前为止所得到的。
Private Sub Worksheet_Calculate()
'Highest Value
Dim r1 As Range: Set r1 = Range("R1")
Dim r2 As Range: Set r2 = Range("R2")
'Lowest Value
Dim r1a As Range: Set r1a = Range("R1")
Dim r2a As Range: Set r2a = Range("R2")
Application.EnableEvents = False
'This registers the highest value
If r1.Value > ao1.Value Then
ao1.Value = r1.Value
End If
If r2.Value > ao2.Value Then
ao2.Value = r2.Value
End If
'This registers the lowest value
If r1a.Value < ap1.Value Then
ap1.Value = r1a.Value
End If
If r2a.Value < ap2.Value Then
ap2.Value = r2a.Value
End If
Application.EnableEvents = True
End Sub
解决方案
推荐阅读
- c# - 如何正确绑定套接字 C#
- tomcat - Tomcat中NIO和BIO的根本区别是什么?
- pine-script - 是否可以在 pine 脚本中创建一条扁平的短线?
- regex - 如何纠正正则表达式中的不平衡括号错误?
- vb.net - 我的控制台应用程序在启动后关闭,但如果我以正常方式启动,它可以正常工作
- c# - 使用 LINQ to Objects 过滤和返回布尔值的这两个语句之间是否有“正确”的方式?
- java - 在 try-with-resources 中关闭动态数量的 AutoCloseable 对象
- mips - 不明白这个lw在做什么
- python - 我的血糖模型 Scipy 代码错误
- python - 如何在python中替换unicode dicts值并返回unicode格式