J
John V
Here is an abbreviated version of code that I have borrowed:
Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "GetData" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=True
End Sub
Sub GetData()
<code to pull stock quotes via Web Query>
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=False
End Sub
Questions:
1. I have occasion to put this "on pause" while I update other aspects of
the workbook. I envision one or two buttons that halt execution, then restart
it. How might I do that?
2. What additional code would be needed to stop the queries between the
hours of, say, 4pm and 8am?
Many thanks.
Public RunWhen As Double
Public Const cRunIntervalSeconds = 120 ' two minutes
Public Const cRunWhat = "GetData" ' the name of the procedure to run
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=True
End Sub
Sub GetData()
<code to pull stock quotes via Web Query>
StartTimer
End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat,
Schedule:=False
End Sub
Questions:
1. I have occasion to put this "on pause" while I update other aspects of
the workbook. I envision one or two buttons that halt execution, then restart
it. How might I do that?
2. What additional code would be needed to stop the queries between the
hours of, say, 4pm and 8am?
Many thanks.