Hi all,
I have an issue with some macros I have scheduled to run on various days of the week. I have the below code placed in “ThisWorkbook” of the macro workbook.
Private Sub Workbook_Open()
'Monday
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:44:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:45:00"), "ArchiveBatFile.ArchiveBatFile"
End If
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:46:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
'Tuesday
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("01:59:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("02:00:00"), "HelloThereBatFile.HelloThereBatFile"
End If
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("02:01:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
As you can see on Monday at 11:45pm the ArchiveBatFile macro is scheduled to run and this macro does run correctly at the scheduled time on Monday nights.
However, the macro HelloThereBatFile which is scheduled to run on Tuesday morning at 2am doesn’t run on Tuesday morning. For some reason it ran on Wednesday morning at 2am!
Does anyone know why is this happening?
I have an issue with some macros I have scheduled to run on various days of the week. I have the below code placed in “ThisWorkbook” of the macro workbook.
Private Sub Workbook_Open()
'Monday
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:44:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:45:00"), "ArchiveBatFile.ArchiveBatFile"
End If
If Weekday(Now()) = vbMonday Then
Application.OnTime TimeValue("23:46:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
'Tuesday
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("01:59:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("02:00:00"), "HelloThereBatFile.HelloThereBatFile"
End If
If Weekday(Now()) = vbTuesday Then
Application.OnTime TimeValue("02:01:00"), "CloseAllWorkbooks.CloseAllWorkbooks"
End If
As you can see on Monday at 11:45pm the ArchiveBatFile macro is scheduled to run and this macro does run correctly at the scheduled time on Monday nights.
However, the macro HelloThereBatFile which is scheduled to run on Tuesday morning at 2am doesn’t run on Tuesday morning. For some reason it ran on Wednesday morning at 2am!
Does anyone know why is this happening?