How can i get a macro excel to execute automatically every 5 seconds
How can i get a macro excel to execute automatically every 5 seconds
(OP)
The question pretty much tells it all.
Right now i am using an external program
and doing the sendkeys to ...
It's ok but It would be much better if it was comming from excel.
Right now i am using an external program
and doing the sendkeys to ...
It's ok but It would be much better if it was comming from excel.





RE: How can i get a macro excel to execute automatically every 5 seconds
(quote Help file:)
This example runs my_Procedure 15 seconds from now.
Application.OnTime Now + TimeValue("00:00:15"), "my_Procedure"
This example runs my_Procedure at 5 P.M.
Application.OnTime TimeValue("17:00:00"), "my_Procedure"
This example cancels the OnTime setting from the previous example.
Application.OnTime EarliestTime:=TimeValue("17:00:00"), _
Procedure:="my_Procedure", Schedule:=False
So you need something like:
Dim SaveTime as Date 'global variable keeps track of last time run
Sub Macro1()
SaveTime = Now() + TimeValue("0:00:05")
Application.OnTime SaveTime, "Macro1", Now() + TimeValue("0:10:00"), True
End Sub
See also Excel VB help.
Cheers,
Joerd
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: How can i get a macro excel to execute automatically every 5 seconds