Ontime event question

joelnichols

Active Member
Joined
Apr 13, 2004
Messages
406
Office Version
  1. 2003 or older
Platform
  1. Windows
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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?
 
Upvote 0
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: .
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,268
Members
448,558
Latest member
aivin

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
Back
Top