How do i get an automatic refresh of a worksheet in excel

D

Dan

I have a 2007 Excel worksheet that uses time that is updated to get
information for other cells. Rather than continuously hit the F9 key. I
would like to set an automatic refresh every 20 seconds or so.
 
G

Gary''s Student

Insert the following in a standard module:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 20
Public Const cRunWhat = "The_Sub"
Public Const a = "a"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()
Calculate
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub


and then run the StartTimer macro.
 
D

Dan

Thank you so much....Works perfectly....

Gary''s Student said:
Insert the following in a standard module:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 20
Public Const cRunWhat = "The_Sub"
Public Const a = "a"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()
Calculate
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub


and then run the StartTimer macro.
 
D

Dan

YOU answered my dilema perfectly, Thank you.

Gary''s Student said:
Insert the following in a standard module:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 20
Public Const cRunWhat = "The_Sub"
Public Const a = "a"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()
Calculate
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub


and then run the StartTimer macro.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top