Google Exceltip.com
Account Icon
Shopping Cart
CheckOut

» Execute Command/Sub-Procedure Using Timer in VBA

This example demostrates how to use a timer to call up a sub procedure after a specific set time has passed.

TimeValue Function is used.

In this example, 3-seconds is assigned to the function.
The Application.OnTime alertTime statement is used to call up the sub procedure, msg, when 3-seconds is up.

Sub timerMsg()
Dim alertTime
MsgBox "The alarm will go off in 3 seconds!"
alertTime = Now + TimeValue("00:00:03")
Application.OnTime alertTime, "msg"
End Sub

Sub msg()
MsgBox "Three Seconds is up!"
End Sub
Rate this tip
12 34 5
  RATING: 3.39
  VIEWS: 52431
Compile error "Method or data member not found"
Begginner wrote on December 31, 1969 19:00 EST
On running the code above in Access
the .OnTime is highlighted and a message comes up saying:
Method or data member not found
Execute Command/Sub-Procedure Using Timer in VBA
rdwray@isp.com wrote on December 31, 1969 19:00 EST
Took you code and pasted into excel after trying my own and cannot get either one to work in 2002.



REGISTERED USERS click here to post comments


GUESTSclick here to Register
Name
Comment Title
Comments


Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation