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
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,117
Messages
5,857,479
Members
431,882
Latest member
saaaaaaaaaaaaaaaaaaaaaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top