VBA宏更新单元格(a,b)="=RTD(serv,,title,source),然后继续使用接收到的值进行某些计算。问题是(1)我事先不知道source是否存在,所以我必须猜测,以及(2)如果source存在,单元格通常不会按时更新。(3)简单等待没有帮助。(4)终止宏通常可以,但我必须求助于手动重新启动。(5)使用以下命令暂停宏运行:
Sub Break_And_Go()
Dim Brk As String
Dim Entr As String
Dim Esc As String
Brk = "{BREAK}"
Entr = "{ENTER}"
Esc = "{ESC}"
' use "send key to simulate manual stop and go"
Application.EnableCancelKey = xlDisabled
Application.SendKeys Esc, True
DoEvents
Application.Wait (Now + TimeValue("00:00:01"))
Application.rtd.RestartServers
Application.rtd.RefreshData
Application.SendKeys Entr, True
Application.Wait (Now + TimeValue("00:00:01"))
DoEvents
Application.EnableCancelKey = xlInterrupt
' Application.OnTime Now + TimeValue("00:00:05"), "Break_And_Go", False
End Sub ' Break_And_Go上述方法不能可靠地工作。尤其是在对多个单元格索引的长循环中。有时所有单元格都会更新,有时一些单元格会留下"N/A",有时什么也不会更新。当在视觉上检查源代码时,通常会有一个差异:源代码存在,而更新失败。
发布于 2017-03-18 08:15:51
对我来说,设置Application.EnableCancelKey = value不再有效,而它过去是有效的。它对你有效吗?这也可能是你的问题所在
您的application.calculation状态如何?这是重新绘制的问题吗?尝试application.ScreenUpdating=true,然后尝试false
https://stackoverflow.com/questions/42796330
复制相似问题