I wrote a macro AutoPing() that allows to loop itself every 5 minutes. It works between before 23:50. But it gets error when it passes to next day (00:00).
Please help me solve this error. Thank you.
Please help me solve this error. Thank you.
Sub AutoPing()
Dim NextSchedule As String
If TimeSerial(Hour(Now), Application.WorksheetFunction.Floor(Minute(Time), 5) + 5, 0) <> TimeSerial(23, 55, 0) Then
NextSchedule = TimeSerial(Hour(Now), Application.WorksheetFunction.Floor(Minute(Time), 5) + 5, 0)
Else
NextSchedule = Date + 1 + TimeSerial(0, 0, 0)
End If
Call cmbPingSystem_Click
Application.OnTime EarliestTime:=NextSchedule, Procedure:="AutoPing", Schedule:=True
End Sub