Link to home
Start Free TrialLog in
Avatar of Phil
PhilFlag for United States of America

asked on

Trying to execute Excel procedure at 15 minute intervals

I am trying to write stock market price data to a table starting at 9:45 AM and every 15 interval thereafter during the trading day. At a minimum I want to write the time and closing price. It would also be nice to capture the High and Low price during that interval and write that data as well. I am reading the tick by tick current price from a cell on an Interactive Brokers dde spreadsheet.

Currently I am trying to do this via the Worksheet_Calculate event which pics up the price every time it changes. I would prefer to not use the Excel timer function if possible as I have had many issues in the past when it is running. If there were an external timer app that could be used that does not tie up Excel that would be nice.

Thank you very much!
Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

How about creating a small batch routine that gets run every 15 minutes using Windows scheduler (don't know how but heard of it being done)?

Routine would open Excel file, workbook open routine would do the necessary calculations and updates and then close and save the file.
Avatar of Phil

ASKER

I am almost there. I wrote the following code to test but it can't find the procedure (error image attached)User generated image:

Private Sub CommandButton1_Click()
    Application.OnTime TimeValue("09:43:00"), "doWriteData"

End Sub

Sub doWriteData()
    MsgBox "works"
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Phil

ASKER

Thank you very much, putting the code in an standard module did the trick. Thanks again!