ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   OnTime VB (https://www.excelbanter.com/excel-discussion-misc-queries/88824-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


Ardus Petus

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

HTH
--
AP

a écrit dans le message de news:
...
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
 
This looks funny to me:

RunWhen = Time() = #12:00:00 AM# + TimeSerial(24, 0, 0)

Maybe:

RunWhen = date + TimeSerial(23, 59, 59)
or
RunWhen = date + 1

Chip Pearson has lots of instructions at:
http://www.cpearson.com/excel/ontime.htm


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

[email protected]

OnTime VB
 
now with something like RunWhen = date + TimeSerial(23, 59, 59)
would that automatically refresh every day- or would it just do that
one day?


Dave Peterson

OnTime VB
 
It would only do it once.

But you could have your code set up the next time right after that time
finishes.

Chip shows you how at that link.

wrote:

now with something like RunWhen = date + TimeSerial(23, 59, 59)
would that automatically refresh every day- or would it just do that
one day?


--

Dave Peterson

Chip Pearson

OnTime VB
 
It would run only once. See www.cpearson.com/excel/ontime.htm

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
ups.com...
now with something like RunWhen = date + TimeSerial(23, 59, 59)
would that automatically refresh every day- or would it just do
that
one day?





All times are GMT +1. The time now is 08:30 AM.

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