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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,223,275
Messages
6,171,123
Members
452,381
Latest member
Nova88

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