【发布时间】:2017-04-06 18:52:30
【问题描述】:
我有一个 VBA 脚本,它以 y 个时间步从 0 计数到 x,并将这个值放在一个单元格中。通过使用偏移公式,我可以使用此计数从另一张表中读取数据,然后将其用于动画 xy 散点图。
使用的代码是。
Sub Counter() 'Name and start of script
For j = 0 To 200 Step 1 'Start of For loop setting j to equal a count from 0 to 2400
Range("A1").Value = j 'Place the value of j into cell A1
For c = 1 To 2500000 'Set a new variable called c and count from 0 to a value, this acts to slow down j's count else the animation would not be very long. Increasing this number will slow down the simulation and decreasing will speed it up
Next 'Move onto the next event
DoEvents 'Tells excel to do the For loop
Next 'Move onto the next event
End Sub
为了使动画图表不运行得很快,它有一个浪费时间计数。这很大程度上取决于计算机的速度。 (较旧的计算机计数较少)
我想要实现的是能够在以秒为单位的时间段内从零计数到 x,因为我的数据通常以 0.1 个时间间隔在 0 到 20 秒内生成。
因此,动画将运行与计算数据相同的时间。
【问题讨论】:
-
听起来像是
Sleep的候选人