Take as example the following code which should state whether the content of Cell A3 is greater or smaller than 0.25, where in Cell A3 we have a formula like RAND() whoch generates random numbers between 0 and 1.
以下面的代码为例,它应说明Cell A3的内容是大于还是小于0.25,其中在Cell A3中我们有一个像RAND()那样的公式,它产生0到1之间的随机数。
Private Sub Worksheet_Change(ByVal Target As Range)
Calculate
If Range("A3") > 0.25 Then
Range("B3") = "greater than 0.25"
Else: Range("B3") = "smaller than 0.25"
End If
End Sub
How to make this Event conditions to be verified in continuous time?
如何在连续时间内验证此事件条件?
2 个解决方案
#1
0
What about using timer? this function calls each 1 second
那么使用计时器呢?这个函数每1秒调用一次
Sub Test()
Calculate
If Range("A3") > 0.25 Then
Range("B3") = "greater than 0.25"
Else
Range("B3") = "smaller than 0.25"
End If
Application.OnTime Now + TimeSerial(0, 0, 1), "Test"
End Sub
#2
0
I think there is no option for that. Have been looking for it myself. There is no change event for calculated cells. The only option is to check dependencies of a calculated field but in this case there are none.
我认为没有选择。一直在寻找它。计算的细胞没有变化事件。唯一的选择是检查计算字段的依赖关系,但在这种情况下没有。
#1
0
What about using timer? this function calls each 1 second
那么使用计时器呢?这个函数每1秒调用一次
Sub Test()
Calculate
If Range("A3") > 0.25 Then
Range("B3") = "greater than 0.25"
Else
Range("B3") = "smaller than 0.25"
End If
Application.OnTime Now + TimeSerial(0, 0, 1), "Test"
End Sub
#2
0
I think there is no option for that. Have been looking for it myself. There is no change event for calculated cells. The only option is to check dependencies of a calculated field but in this case there are none.
我认为没有选择。一直在寻找它。计算的细胞没有变化事件。唯一的选择是检查计算字段的依赖关系,但在这种情况下没有。