gint32
01-23-2017, 12:51 PM
Is there a way via vba to automate a popup message box when certain times of the day is reached, with being to task heavy, lets say having a macro check systems time every 15minutes or so, using a call to wait a while , like sleep
thanks in advance for any advice
Calculate
Sleep (150000) ' delay
or application.Wait(Now + TimeValue("00:00:01"))
Option Explicit
Sub ScheduleNext()
'Schedules the macro to run again in one hour
If TimeValue(Now) = TimeValue("03:40:00 AM") Then
Application.OnTime TimeValue("03:40:00 AM"), "msgboxA"
ElseIf TimeValue(Now) < TimeValue("03:40:00 AM") Then
Application.OnTime Now + TimeValue("03:42:00 AM"), "msgboxb"
' do nothing
End If
End Sub
Sub msgboxA()
msgbox " Time for to do something"
End Sub
Sub msgboxb()
msgbox " No Time to do something"
End Sub
thanks in advance for any advice
Calculate
Sleep (150000) ' delay
or application.Wait(Now + TimeValue("00:00:01"))
Option Explicit
Sub ScheduleNext()
'Schedules the macro to run again in one hour
If TimeValue(Now) = TimeValue("03:40:00 AM") Then
Application.OnTime TimeValue("03:40:00 AM"), "msgboxA"
ElseIf TimeValue(Now) < TimeValue("03:40:00 AM") Then
Application.OnTime Now + TimeValue("03:42:00 AM"), "msgboxb"
' do nothing
End If
End Sub
Sub msgboxA()
msgbox " Time for to do something"
End Sub
Sub msgboxb()
msgbox " No Time to do something"
End Sub