Heylo, How is your office life going on? I pray for all of you and wish you lots of wealth and a very good health. Coming to our topic, we're actually gonna discuss Application.OnTime Object of Application class.
For details: Please visit Microsoft MSDN here:
http://msdn.microsoft.com/en-us/library/aa195809(office.11).aspx
We used Now + TimeValue(time) in our example to schedule something to be run when a specific amount of time (counting from now) has elapsed as TimeValue(time) is used to schedule something to be run a specific time.
For e.g.
1. This example runs my_Procedure 15 seconds from now.
Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"
2. This example runs my_Procedure at 5 P.M.
Application.OnTime TimeValue("17:00:00"), "my_Procedure"
Sample Code:
Option Explicit
Sub ScheduleAMacro()
Application.OnTime Now + TimeSerial(0, 1, 0), "AlarmMacro"
End Sub
'This should be the macro that runs after one minute
'We simply pops up a message box.
Sub AlarmMacro()
MsgBox "The code was just executed!"
End Sub
For details: Please visit Microsoft MSDN here:
http://msdn.microsoft.com/en-us/library/aa195809(office.11).aspx
We used Now + TimeValue(time) in our example to schedule something to be run when a specific amount of time (counting from now) has elapsed as TimeValue(time) is used to schedule something to be run a specific time.
For e.g.
1. This example runs my_Procedure 15 seconds from now.
Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"
2. This example runs my_Procedure at 5 P.M.
Application.OnTime TimeValue("17:00:00"), "my_Procedure"
Sample Code:
Option Explicit
Sub ScheduleAMacro()
Application.OnTime Now + TimeSerial(0, 1, 0), "AlarmMacro"
End Sub
'This should be the macro that runs after one minute
'We simply pops up a message box.
Sub AlarmMacro()
MsgBox "The code was just executed!"
End Sub
Comments
VBA code is compiled during excel work
Many thanks
The réason it says is that "the macro may not be available in this workbbok or all macros may be disabled".....
But the macro is in the same workbook and all macros are enabled.
it says "the macro may not be available in this workbook or all macros may be disabled"
but the macro is in the same workbook and all macros are enabled.
it says "the macro may not be available in this workbook or all macros may be disabled"
but the macro is in the same workbook and all macros are enabled.