Write the VBA code in connected Excel sheet?

Questions about integrating Excel and Cymatic, programming, formulae, etc

Write the VBA code in connected Excel sheet?

Postby Gcoopermax » Mon Feb 04, 2019 9:16 am

I am trying to create a VBA code to monitor the odds every second and fire bets when certain conditions are met etc. While I can manage the code, I want to know whether:

#1) to save it in the main Workbook to which Cymatic is linked (preferable)
#2) to create a "mirror" workbook and dynamically link it to main workbook

Since my macro has to monitor the odds after every sec, it has to keep running until I trade out.But if go with option #1 and try to test the code offline (i.e. Excel disconnected from Cymatic), I am unable to change the values in Cymatic spreadsheet. So I don't know whether it will work flawlessly if I run the macro in it. With Option #2, since VBA code is running in a different workbook, I can change odds in main workbook and they update real time in the mirror workbook and adequate bets can be fired in main workbook.

Which of these options is better? I have qualms about #2 because if the dynamic link between the workbooks doesn't work well, I will lose out on opportunities.
Gcoopermax
 
Posts: 1
Joined: Fri Feb 01, 2019 6:06 am

Re: Write the VBA code in connected Excel sheet?

Postby Gavin » Mon Feb 04, 2019 9:03 pm

Hi Gcoopermax,

Thanks for your question.

I'll presume that you are intentionally talking about Workbooks (separate Excel files), as opposed to Worksheets (separate tabs within one Excel file).

I wouldn't recommend using two workbooks (two files), because I expect Excel will work faster if you keep everything in one Workbook.

Gcoopermax wrote:I am unable to change the values in Cymatic spreadsheet.


You can type values into it, but I presume that you mean that they don't triggered your macro?

That is correct. If your macro code is placed in the Worksheet_Calculate events, then it probably won't be triggered if you simply type a new value in the prices in the Cymatic worksheet. To force the macro to be triggered in those circumstances, I think you could just put a formula in a spare cell that refers to the cell in which you want to type new sample prices. For example go to a spare cell (lets say BA1 for example), then input a formula such as =D8, if D8 is the cell where you want to type a new value during testing. So a change in a value in D8 will cause the formula in cell BA1 to recalculate. Any formula recalculating will then cause the Worksheet_Calculate event to be triggered because it has to recalculate. So your macro will therefore be triggered (assuming the code for your macro is inside the Worksheet_Calculate event).

This also probably explains why you are able to manually trigger your macro by keeping it in a separate workbook (or worksheet) with formula pointing back to the main workbook. Those formulae get recalculated when you change a value in the main workbook, hence triggering the Worksheet_Calculate event to fire.

Kind regards,

Gavin
User avatar
Gavin
Site Admin
 
Posts: 3835
Joined: Wed Jan 23, 2013 9:11 pm
Location: United Kingdom


Return to Excel - Help / Support

Who is online

Users browsing this forum: No registered users and 0 guests

cron