Move VBA code to different Module

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

Move VBA code to different Module

Postby bolpx001 » Sun Apr 26, 2020 2:36 pm

Hi All in these crazy crazy times, I am hoping somebody can offer some assistance help with an issue I have. I have written a VBA routine to place two bets on a horse using the COM facilities of BA The routine lives in the VBA module of a sheet I called Refresh and depends on the Worksheet Change event. The Routine works very well and I am very pleased with it but now I want to move it into another module and incorporate it into my betting routines.
My reason for wanting to do this is because every time I try to read or write to another sheet I get a run-time error which makes it very difficult to incorporate it into my normal betting routines. Also I don’t want the routine triggering every time the Refresh sheet is updated.
The error I got when I tried to move the routine was Compile Error Only valid in object Module. Can somebody please throw some light on this for me.
Many thanks - Paul
bolpx001
 
Posts: 297
Joined: Sat Nov 19, 2005 4:30 am
Location: Dublin, Ireland

Re: Move VBA code to different Module

Postby alrodopial » Mon Apr 27, 2020 9:00 am

The worksheet change event is only valid in object modules , ie "sheet" object or "thisworkbook" object
I assume that you want to move your code in a "normal" module but it wan't work
You should find a new way of "activating/starting" the code if you place the code in a normal module

If you keep it in the "sheet" object try modifying the below:

If Target.Address = "$A$1" Then
............... your code here
alrodopial
 
Posts: 1353
Joined: Wed Dec 06, 2006 9:59 pm

Re: Move VBA code to different Module

Postby bolpx001 » Tue Apr 28, 2020 1:07 am

Thanks alrodopial I think I will try something like that. I hope you are well in these difficult times :)
best regards - Paul
bolpx001
 
Posts: 297
Joined: Sat Nov 19, 2005 4:30 am
Location: Dublin, Ireland


Return to Discussion

Who is online

Users browsing this forum: No registered users and 23 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.

cron