Hi all

I have an application that reads data from a webpage which is updated at 03:45 daily. Occasional updates to the webpage are also carried out at other times, I am notified of these by email.

I have written this code which should update every morning at 4am and, after hitting a button, when I am emailed notification of an update:

Option Explicit


Global AutoRun As Boolean


Sub AutoUpdate()
    Application.OnTime ("04:00:00"), "UpdateData"
End Sub


Sub ManualUpdate() 'run by a command button
    AutoRun = False
    UpdateData
End Sub


Sub UpdateData()
    'Code to update here...
    If AutoRun Then AutoUpdate
    AutoRun = True
End Sub
I seldom use OnTime so I am seeking advice as to whether this is okay to go with, or if there is a better way to approach this.

Any pointers would be most welcome

Thanks in advance