×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How can i get a macro excel to execute automatically every 5 seconds
2

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.

RE: How can i get a macro excel to execute automatically every 5 seconds

2
There is the Application.OnTime method. It runs your macro on a specified time:
(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

(OP)
Ok thank you !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close