Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I want to run a macro every half hour, do I use the
OnTime method? This is what I have tried: Dim KeepingTime As Boolean Dim Times As Long Times = 10 KeepingTime = True Do While KeepingTime = True Application.OnTime Now + TimeValue ("00:30:0"), "GetAll" Times = Times - 1 If Times < 1 Then KeepingTime = False End If Loop Scott |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have an example on my website
-- Rob van Gelder - http://www.vangelder.co.nz/excel "Scott" wrote in message ... If I want to run a macro every half hour, do I use the OnTime method? This is what I have tried: Dim KeepingTime As Boolean Dim Times As Long Times = 10 KeepingTime = True Do While KeepingTime = True Application.OnTime Now + TimeValue ("00:30:0"), "GetAll" Times = Times - 1 If Times < 1 Then KeepingTime = False End If Loop Scott |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the help!!!
-----Original Message----- I have an example on my website -- Rob van Gelder - http://www.vangelder.co.nz/excel "Scott" wrote in message ... If I want to run a macro every half hour, do I use the OnTime method? This is what I have tried: Dim KeepingTime As Boolean Dim Times As Long Times = 10 KeepingTime = True Do While KeepingTime = True Application.OnTime Now + TimeValue ("00:30:0"), "GetAll" Times = Times - 1 If Times < 1 Then KeepingTime = False End If Loop Scott . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the help!!!
-----Original Message----- I have an example on my website -- Rob van Gelder - http://www.vangelder.co.nz/excel "Scott" wrote in message ... If I want to run a macro every half hour, do I use the OnTime method? This is what I have tried: Dim KeepingTime As Boolean Dim Times As Long Times = 10 KeepingTime = True Do While KeepingTime = True Application.OnTime Now + TimeValue ("00:30:0"), "GetAll" Times = Times - 1 If Times < 1 Then KeepingTime = False End If Loop Scott . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Change
Dim Times As Long to Static Times As Long otherwise a new local variable will be created each time the Sub is run. One alternative: Public Sub GetAll() Static Times As Long Static bAlreadyRun As Boolean If Not bAlreadyRun Then Times = 10 bAlreadyRun = True End If 'do stuff here Times = Times - 1 If Times = 1 Then _ Application.OnTime Now + TimeSerial(0, 30, 0), "GetAll" End Sub In article , "Scott" wrote: If I want to run a macro every half hour, do I use the OnTime method? This is what I have tried: Dim KeepingTime As Boolean Dim Times As Long Times = 10 KeepingTime = True Do While KeepingTime = True Application.OnTime Now + TimeValue ("00:30:0"), "GetAll" Times = Times - 1 If Times < 1 Then KeepingTime = False End If Loop Scott |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Convert time to Half Hour inverval | Excel Discussion (Misc queries) | |||
How do I round time down to the nearest half hour? | Excel Worksheet Functions | |||
Add half hour | Excel Discussion (Misc queries) | |||
Convert Time To Half Hour - Pt 2 - OOPS! | Excel Discussion (Misc queries) | |||
Calculate time difference to the half hour | Excel Worksheet Functions |