Excel 2010:更频繁的外部数据刷新与VBA?
Excel 2010允许您以最快的设置每分钟刷新一次外部数据源:
数据 – >属性 – >刷新每一个
什么是最好的VBA不断更新连接不到一分钟? 理想情况下,我想为每个连接设置刷新率,但全部刷新就足够了。
以下方法工作:
在这本书中,
Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next If Cancel = False Then Application.OnTime dTime, "RefreshIt", , False On Error Goto 0 End Sub Private Sub Workbook_Open() Run "RefreshIt" End Sub
在一个新的模块中,
Public dTime As Date Sub RefreshIt() Sheets(1).Range("A1").QueryTable.Refresh dTime = Time + TimeValue("00:00:30") Application.OnTime dTime, "RefreshIt" End Sub
感谢戴夫霍利在以下论坛http://www.ozgrid.com/forum/showthread.php?t=24119