How would I have a macro run at a certain time or at certain times without having it occupied with constantly polling the clock?
How would I have a macro run at a certain time or at certain times without having it occupied with constantly polling the clock?
check out the OnTime method
I read quite a few write-ups on the OnTime Method, a method to which I had had a brief and vague exposure but about which I had forgotten. Most of the write-ups offered little more than the correct syntax and a couple of examples. One of them stated that it could be used for the periodic execution of a subroutine without offering anything regarding how. Over the years I've come to expect glaring omissions in "free" information from Microsoft, but it seems that a disturbingly high percentage of techs may be following their lead. In their defense, I suppose they get at least as frustrated with Microsoft as I do. It was not until I came across a write-up that explained scheduling the initial trigger from a subroutine named workbook_open() and scheduling each subsequent trigger from within the scheduled subroutine that it all clicked. My workbook now does exactly what I want it to do. I got it to run MySub (name changed) every quarter-hour on the quarter-hour by including the following line in both workbook_open and MySub:Application.OnTime WorksheetFunction.RoundUp(Now * 96, 0) / 96, "MySub"Many thanks for steering me in the right direction!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks