Excel 2010 lets you refresh external data sources once a minute at the fastest settings in:
Data -> Properties -> Refresh every
What is the best vba to continously update from connections under a minute? Ideally I would like to set refresh rates for each individual connection but Refresh All is sufficient.
The following method works:
In ThisWorkbook,
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
In a new module,
Public dTime As Date
Sub RefreshIt()
Sheets(1).Range("A1").QueryTable.Refresh
dTime = Time + TimeValue("00:00:30")
Application.OnTime dTime, "RefreshIt"
End Sub
Thanks to Dave Hawley on the following forum http://www.ozgrid.com/forum/showthread.php?t=24119
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With