simple macro to execute every 15 seconds

eventrader

New Member
Joined
Jul 1, 2010
Messages
10
I need a simple macro to execute every 15 seconds. The macro is to call two other macros every 15 seconds .Here is my code:

Sub ibstartstop()
'
' ibstartstop Macro
' Start stop running IB10 sec macro every 15 sec
'
' Keyboard Shortcut: Ctrl+x
'
Application.OnTime Now, "ib15sec"
dTime = Now + TimeValue("00:00:15")
Application.OnTime dTime, "ib15sec"
Application.OnTime dTime, "a"


End Sub

The macro starts fine and calls the other two macros, but does not repeat the process every 15 seconds.

PLEASE HELP
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Your not looping it:
Code:
Sub ibstartstop()
'
' ibstartstop Macro
' Start stop running IB10 sec macro every 15 sec
'
' Keyboard Shortcut: Ctrl+x
'
do
Application.OnTime Now, "ib15sec"
dTime = Now + TimeValue("00:00:15")
Application.OnTime dTime, "ib15sec"
Application.OnTime dTime, "a"
loop

End Sub
 
Upvote 0
Thanks for your kind help.

When I add loop, i get the following error

Compile error: Loop without Do

please help.
 
Upvote 0
Did you add the do as well?

Sub ibstartstop()
'
' ibstartstop Macro
' Start stop running IB10 sec macro every 15 sec
'
' Keyboard Shortcut: Ctrl+x
'
do
Application.OnTime Now, "ib15sec"
dTime = Now + TimeValue("00:00:15")
Application.OnTime dTime, "ib15sec"
Application.OnTime dTime, "a"
loop

End Sub
 
Upvote 0
Because it is always running, it runs and sits waiting for the 15 second mark and then runs the code. Upon completion it waits for 15 seconds and runs again.
 
Upvote 0
Get rid of the do and the loop, at the end of the last macro it runs put this before the end sub

ibstartstop
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,986
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top