Sub Scheduler()
'Decliration of variables and their types.
Dim wb As Workbook
Dim sh1 As Worksheet
Dim schedule_time As Integer
Dim wait_time As String
Dim r_time As Integer
'Saves the workbook.
ActiveWorkbook.Save
'Sets the current workbook and current sheet to be used.
Set wb = ActiveWorkbook
Set sh1 = wb.Sheets("Reports")
r_time = 60 - Minute(Now())
schedule_time = r_time + 10
If schedule_time = 60 Then
Application.OnTime Now() + TimeValue("01:00:00"), "Hourly_Work"
Else
wait_time = "00:" & CStr(schedule_time) & ":00"
Application.OnTime (Now + TimeValue(wait_time)), "Hourly_Work"
End If
End Sub
________________________________________________________________________________________________________________________
Above is the code. The issue is at the text in red. What this does is it schedules the hourly work for the next hour ten minutes after the hour. Problem is when it schedules, it runs into an issue because the hour has already passed in spring forward time change and gives me a debug error for the line in red. As for the reports it skips the 2o'clock hour line and fills in the 3o'clock hour line instead, which is fine but then stops with the error if the code continues to run and fills in the the other hours as they come up wouldn't be a problem.
'Decliration of variables and their types.
Dim wb As Workbook
Dim sh1 As Worksheet
Dim schedule_time As Integer
Dim wait_time As String
Dim r_time As Integer
'Saves the workbook.
ActiveWorkbook.Save
'Sets the current workbook and current sheet to be used.
Set wb = ActiveWorkbook
Set sh1 = wb.Sheets("Reports")
r_time = 60 - Minute(Now())
schedule_time = r_time + 10
If schedule_time = 60 Then
Application.OnTime Now() + TimeValue("01:00:00"), "Hourly_Work"
Else
wait_time = "00:" & CStr(schedule_time) & ":00"
Application.OnTime (Now + TimeValue(wait_time)), "Hourly_Work"
End If
End Sub
________________________________________________________________________________________________________________________
Above is the code. The issue is at the text in red. What this does is it schedules the hourly work for the next hour ten minutes after the hour. Problem is when it schedules, it runs into an issue because the hour has already passed in spring forward time change and gives me a debug error for the line in red. As for the reports it skips the 2o'clock hour line and fills in the 3o'clock hour line instead, which is fine but then stops with the error if the code continues to run and fills in the the other hours as they come up wouldn't be a problem.