Stop code running

  • Thread starter Thread starter kevin carter
  • Start date Start date
K

kevin carter

Hi,
i have this code running in a workbook, te code calls a macro that
updates all the links in the workbook

Sub auto_open()

ThisWorkbook.Application.OnTime TimeValue("06:05:00"), "update"
ThisWorkbook.Application.OnTime TimeValue("07:05:00"), "update"
ThisWorkbook.Application.OnTime TimeValue("08:05:00"), "update"
ThisWorkbook.Application.OnTime TimeValue("09:05:00"), "update"
end sub

this works fine
however i am fnding that when i close this workbook and have another
workbook open at the te macros is due to run this workbook opens

How can i stop the code running when i close this workbook

thanks

kevin
 
Take a look at Chip Pearson's notes:
http://www.cpearson.com/excel/OnTime.aspx

But you may want to try:

Sub Auto_Close()
On Error Resume Next

Application.OnTime EarliestTime:=TimeValue("06:05:00"), _
Procedure:="update", Schedule:=false

Application.OnTime EarliestTime:=TimeValue("07:05:00"), _
Procedure:="update", Schedule:=false

Application.OnTime EarliestTime:=TimeValue("08:05:00"), _
Procedure:="update", Schedule:=false

Application.OnTime EarliestTime:=TimeValue("09:05:00"), _
Procedure:="update", Schedule:=false
 
Take a look at Chip Pearson's notes:http://www.cpearson.com/excel/OnTime.aspx

But you may want to try:

Sub Auto_Close()
    On Error Resume Next

    Application.OnTime EarliestTime:=TimeValue("06:05:00"), _
         Procedure:="update", Schedule:=false

    Application.OnTime EarliestTime:=TimeValue("07:05:00"), _
         Procedure:="update", Schedule:=false

    Application.OnTime EarliestTime:=TimeValue("08:05:00"), _
         Procedure:="update", Schedule:=false

    Application.OnTime EarliestTime:=TimeValue("09:05:00"), _
         Procedure:="update", Schedule:=false

    On error goto 0
End Sub











--

Dave Peterson- Hide quoted text -

- Show quoted text -

thank you dave i will try it now
 
Back
Top