Help with code

Please post any questions regarding the program here.

Moderator: 2020vision

Help with code

Postby davez » Thu Feb 23, 2012 6:30 am

Hi all, hoping someone can help solve a problem - the worksheet change procedure below work fine & calls a macro at 120sec & 10sec before the jump time but will only run on the worksheet I have currently selected - any ideas on how to get it to run on worksheets I do not have selected? Thanks for any help provided.


Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Columns.Count <> 16 Then

    Application.EnableEvents = False

    With ThisWorkbook.Sheets(Target.Worksheet.Name)
    Select Case .Range("$HM$3").Value
   
    Case 120
    Call Victab_odds_for_main_use
   
   
    Case 10
    Call Victab_odds_for_main_use

   
    End Select
    End With

    Application.EnableEvents = True
       
End If
End Sub
davez
 
Posts: 77
Joined: Thu Jul 29, 2010 5:47 am

Postby osknows » Thu Feb 23, 2012 9:55 am

Hello,

I'm assuming that the procedure 'Victab_odds_for_main_use' writes to the sheet also?

You need to tell it which sheet to write to

Eg this will only write to the active sheet


Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
    Call Victab_odds_for_main_use
End Sub

sub Victab_odds_for_main_use()
  range("A1").value  ="Called"
end sub


this will write to whichever sheet you pass

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
   
    Call Victab_odds_for_main_use(Target.Parent)

    'or
    Set ws = Sheet3
    Call Victab_odds_for_main_use(ws)
   
    Application.EnableEvents = True
End Sub

Sub Victab_odds_for_main_use(ByVal ws As Worksheet)
    With ws
        .Range("A1").Value = "Called"
    End With
End Sub
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby davez » Fri Feb 24, 2012 12:06 am

Thanks osknows, is there any chance you could amend the code I posted as I have tried to incorporate what you have posted without any luck.

I think the main problem I face is that as I have a sheet for each race & linked to BA, each worksheet name can be variable & I have been unable to work out how to reference 'this sheet'.
davez
 
Posts: 77
Joined: Thu Jul 29, 2010 5:47 am

Postby davez » Fri Feb 24, 2012 6:11 am

cancel that osknows, ive worked it out, thanks for your help
davez
 
Posts: 77
Joined: Thu Jul 29, 2010 5:47 am


Return to Help

Who is online

Users browsing this forum: No registered users and 35 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.