#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 2 Timers

Hi Al

I'd put a "what time is is ?" check into the 30 sec loop and have that one
call the once-an-hour-procedure at the right time. But you provide too
little detail to make me say "That's the very best solution" ;-)

HTH. Best wishes Harald


"Al" skrev i melding
...
I have code that runs every 30 second to update a file. I have another

macro
that I need to run at 15 minutes after the hour to update another file.

What
is the best approach to accomplish this?
Thanks for the help!
Al



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default 2 Timers


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=True
If Minute(Time) = 15 Then
If Second(Time) <= 30 Then UpdateOtherFile
End If
End Sub

HTH. Best wishes Harald

"Al" skrev i melding
...
OK Here is the 30 second code.....

Public RunWhen As Double
Public Const cRunIntervalSeconds = 30
Public Const cRunWhat = "Macro2"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,

schedule:=True
End Sub


Sub Stop_Timer()
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,

schedule:=False

End Sub


Sub Macro2()
Application.ScreenUpdating = False

On Error Resume Next
Kill "G:\Operations Planning\PowerWorld\mwdata.xls"
On Error GoTo 0
Workbooks.OpenText Filename:="G:\MyPath\Myfile.txt _
Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,

_
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), _
Array(2, 1)), TrailingMinusNumbers:=True
ActiveWorkbook.SaveAs Filename:= _
"G:\mypath\myfile.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False
' added line to schedule the next run
StartTimer
Application.ScreenUpdating = True
End Sub

Then every hour at 15 after my sub UpdateOtherFile() would run




"Harald Staff" wrote:

Hi Al

I'd put a "what time is is ?" check into the 30 sec loop and have that

one
call the once-an-hour-procedure at the right time. But you provide too
little detail to make me say "That's the very best solution" ;-)

HTH. Best wishes Harald


"Al" skrev i melding
...
I have code that runs every 30 second to update a file. I have

another
macro
that I need to run at 15 minutes after the hour to update another

file.
What
is the best approach to accomplish this?
Thanks for the help!
Al






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding up a part timers days in Excel jon boy Excel Discussion (Misc queries) 2 October 15th 07 08:03 AM
Countdown timers Mike Excel Programming 3 May 25th 04 05:18 AM
Using timers within excel Filip Excel Programming 1 April 30th 04 02:51 PM
Timers Khai[_2_] Excel Programming 2 September 16th 03 05:25 PM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"