Ontime event question

joelnichols

Active Member
Joined
Apr 13, 2004
Messages
384
I have asked about this in several other threads but never had a solution.

When I run an Application.OnTime event it always runs the event 2 or more times. Anyone else have this happen or know why it happens? Its not specific to 1 workbook so its not code error in the macros im running.

Thanks
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,453
Hello joelnichols,
Can't say as I know off hand why it's doing that (and no, I haven't had the same problem), but I gotta say I like your signature quote. :LOL:

Can you post your code for us, along with any other code it may be calling?
 

joelnichols

Active Member
Joined
Apr 13, 2004
Messages
384
Strange..I have repeated the steps which led to the macros repeating and now it doesnt happen. Maybe it was something left in memory that caused the "hiccup"? Oh well nevermind :rolleyes: .
 

Fat Cat

Active Member
Joined
Nov 5, 2004
Messages
336

ADVERTISEMENT

I found this happen a few times and it appeared to relate to sheduled events remaining on the shedule after I closed the workbook. If I reopened the book I got both the remaining event from last time plus the new one. If I didn't make sure the shedule was cleared from Excels to do list, the event would pop up and run even if I had closed the book and even after closing Excel. It would simply open the workbook again and run the sheduled process.

In the end, I resorted to storing the sheduled time in a variable each time I sheduled an OnTIme event to occur and then when closing the workbook would clear the event. On Error Resume Next gets around sthe problem of trying to stop a non-existant OnTime event.
 

joelnichols

Active Member
Joined
Apr 13, 2004
Messages
384
I know what your refering to but its different from the problem I had. My macro opened IE and copy/pasted pages to a book, but it would open 3 IE windows and paste the page 3 times, 1 on top of the other.
 

Fat Cat

Active Member
Joined
Nov 5, 2004
Messages
336
Have you tried stepping through your code to see if 3 OnTime events are actually being sheduled. Go to the code where you macro starts and just hit F8 for each line. An outside chance is your code might trigger some other sort of event (eg: a worksheet change or something) that recalls the OnTime sheduling code.

I also once resorted to inserting a line of code infront of the OnTime command to write out the sheduled time (hh:mm:ss) that will be used to the next free cell on a worksheet to see if it the multiple events had the same sheduled times or different times. You could use a msgbox to do the same I suppose. If you get 3 times that are different = the OnTime event is being called on 3 separate occasions. If you get 3 times that are the same, its being called 3 times at the same time.

What would be really nice, but I don't know how to do it, is to be able to display the sheduled to do list to see whats on it.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,081
Messages
5,570,088
Members
412,310
Latest member
mark884
Top