Auto Update

.Justin

Registered User.
Local time
Today, 19:04
Joined
Jun 29, 2009
Messages
38
Hi there, I have a macro that i would like to run automaticley every day 10 seconds? I can;t work out how to do this... Would someone be able to help me please?

Excel Version 2007
 
Hi, Justin,

maybe Application.OnTime can help:

Code:
'Code for ThisWorkbook
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Call EndProcessing
End Sub

Private Sub Workbook_Open()
    StartProcessing
End Sub
Code:
'module
Public Const ciIntervall As Integer = 10
Public Const dsMacro As String = "YourMacro"
Public gdNextTime As Double
Public gvar As Variant

Sub StartProcessing()
    gdNextTime = Now + TimeSerial(0, 0, ciIntervall)
    Application.OnTime _
            gdNextTime, _
            dsMacro
End Sub

Sub YourMacro()
    'your code
    Call StartProcessing
End Sub

Sub EndProcessing()
    On Error Resume Next
    Application.OnTime _
            earliesttime:=gdNextTime, _
            procedure:=dsMacro, _
            schedule:=False
    Application.Calculation = gvar
End Sub
Ciao,
Holger
 

Users who are viewing this thread

Back
Top Bottom