PureBytes Links
Trading Reference Links
|
since someone answered the method already, I would like to
point out 2 things:
1. make sure you do not have the timer go close to or below 1 sec
per call, otherwise excel will be too busy and from time to time stop
the other process in the background if the excel is pre version 97.
That includes your omega server if you use it on the same machine
to collect real time data :)
2. have a onclose vba code to disable the timer - when the timer
is called too often, you can never exit excel or close the workbook
due to its content keep changing. again pre version 97 the problem
is worst, and it seems the latest ones can avoid the trouble itself.
just my experience.
-Lawrence Chan
----- Original Message -----
From: Rich Estrem <estrem@xxxxxxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Friday, November 26, 1999 1:58 PM
Subject: Re: Excel Macro timed execution
>
> At 10:27 AM 11/26/99 -0800, you wrote:
> >What's the best way to get an Excel Macro to execute once a minute
without
> >having to remember to got to the Excel window and press the associated
> button?
> >
> >
>
> Ullrich -
>
> Here is some vba code to do what you want. There are 2 macro's :
> 1 to run on a timed interval and a second one to turn off the timer.
> I assign them both to buttons on the sheet to make it easy to
> run them.
>
> regards,
> Rich
>
>
>
> Dim NextTime As Date
>
> Sub mytimer()
> NextTime = Now + TimeValue("00:01:00")
>
> 'put your macro code here
>
> 'test code below increments a cell by 10 on the timer
> mynum = Cells(1, 2).Text
> mynum = mynum + 10
> Cells(1, 2).Formula = mynum
>
> Application.OnTime NextTime, "mytimer"
> End Sub
>
> Sub StopIt() 'turns off the timed macro above
> Application.OnTime NextTime, "mytimer", schedule:=False
> End Sub
>
>
>
>
>
|