Need a Timer in Excel?

Author: Oliver Phillips, Friday, November 28, 2008, Posted in desktop
Tags: ,

For some Excel applications, you might want a timer so that a routine can run every so often.  You could send your VBScript macro into an eternal loop, and check the time with each cycle - but that’s quite processor intensive.

You can create a timer using web queries.  These have a built in auto refresh facility.  Set it to a minute, an hour, six hours whatever you need.  Make the target of your web query a piece of data that will have changed at each refresh - many web pages include the time on them so use one of those.

So how does that help me run my application you’re asking?  This is how.  Set an onchange event procedure for the worksheet which holds your web query and include a call to the sub routine you want to run.  At the set interval, the web query refreshes, the data retrieved is different, which fires the onchange event which runs the procedure which calls your vbscript code. 

You now have a simple robust timer that won’t hog your computer’s resources

 

Leave a Reply