ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   OnTime VB (https://www.excelbanter.com/excel-worksheet-functions/88883-ontime-vbulletin.html)

[email protected]

OnTime VB
 
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


Bob Phillips

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




Dave Peterson

OnTime VB
 
You have more responses at your other thread.

wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com