MrExcel Publishing
Your One Stop for Excel Tips & Solutions

ONtime with addin disaster. please help

Posted by adam k on February 12, 2001 11:51 AM

I recently had a disaster and I thought you might help if possible. I have 10 people accesssing one excel addin. I ran an ontime loop on one of the spreadsheets and I closed the workbook. Unfortunately I didn't realize that this would not stop the ontime macro from running because Excel was still open. For some reason all the other spreadsheet started running the code i think, even though the ontime macro was only in one of the sheets, not the addin. thanks for your help in advance. adam k.

Posted by Celia on February 12, 2001 4:26 PM

You need to set the OnTime event to False.
This could be done by a Workbook_BeforeClose procedure in the workbook that has the OnTime event.
Something like this :-
Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime Now + TimeValue("00:03:00"), "Repeat", schedule:=False
End Sub

Change ' OnTime Now + TimeValue("00:03:00"), "Repeat", ' to fit your situation.