Thread: OnTime VB
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default OnTime VB

This makes more sense

Sub StartTimer()

RunWhen = Date + 1 + TimeSerial(12, 0, 0)
Application.OnTime earliesttime:=RunWhen, procedu="The_Sub", _
schedule:=True
End Sub

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

wrote in message
oups.com...
I want to refresh my data every day at 12am. Does something like this
make sence?

Public RunWhen As Double

Sub StartTimer()

RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)
Application.OnTime earliesttime:=RunWhen, procedu="The_Sub", _
schedule:=True
End Sub

Sub The_Sub()


ActiveWorkbook.RefreshAll
StartTimer

End Sub