Private Sub Workbook_SheetChange in a Sheet

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

Moderator: 2020vision

Private Sub Workbook_SheetChange in a Sheet

Postby Fixador » Tue Dec 03, 2013 2:59 pm

Once more engaged in the precious and refined art of deepening the dent in the wall plaster with my head :roll:

Prior, I have always used Private Sub Workbook_SheetChange in ThisWorkbook before.... but now I am getting cocky and trying to use in a sheet instead ! ( so only Private Sub WorkBook_Open() ) is in the ThisWorkbook.

Following is the code in a sheet named "Mkt-1" ( BA feeds data into cell A10 )

This is an WinXP sp3 pc with Excel 2003 with BA ver 1.1.0.66x84


Code: Select all
Option Explicit
'Private Const strCountdownCell1 As String = "D11"     'moved from  ThisWorkbook - now disabled

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim c As Range, dblLastSnap As Double, sht1 As Worksheet, sht2 As Worksheet
Dim Racename As String, myHour As Variant, myMin As Variant, ShtMarker As Integer, mySeqRow As Integer

Dim strCountdownCell1 As String     'moved from  ThisWorkbook & mod

If (Target.Worksheet.name <> "Mkt-1") Then Exit Sub
If Target.Columns.count <> 16 Then Exit Sub

'>>>>>>>>>>market identifier for this sheet >>>>>>>>>>>>>>>>>>>>>
ShtMarker = 1
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
If ShtMarker = 1 Then Set sht1 = ThisWorkbook.Worksheets("Mkt-1")
If ShtMarker = 2 Then Set sht1 = ThisWorkbook.Worksheets("Mkt-2")

Set sht2 = ThisWorkbook.Worksheets("MyBets")
'There needs to be a sequence
'control for each of the markets: PUT ALL in'MyBets'
If ShtMarker = 1 Then mySeqRow = 4
If ShtMarker = 2 Then mySeqRow = 6

Application.ScreenUpdating = False
ThisWorkbook.Worksheets.Application.EnableEvents = False: ThisWorkbook.Worksheets.Application.Calculation = xlCalculationManual
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'---------------------------   core sequencing controls ---------------------------------
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
strCountdownCell1 = Str(sht1.Range("D11"))

For Each c In Target.Cells
    If (c.Address(False, False, xlA1) = strCountdownCell1) And VarType(c) = vbDouble Then
        dblLastSnap = sht1.Range("A1")
        sht1.Range("A1") = c.Value
        If c.Value <= sht1.Range("B2") And dblLastSnap > sht1.Range("B2") Then            '====> Handling on t1
            If sht1.Cells(4, 1) <> sht1.Cells(10, 1) Then ' no point in doing it twice for same race !
                sht1.Cells(7, 24) = "" 'racetime display
                sht1.Cells(8, 21) = "" 'last error
                sht1.Cells(7, 21) = "RESET" 'sequence control display
                Racename = sht1.Cells(10, 1)
                sht1.Cells(4, 1) = sht1.Cells(10, 1)
                sht1.Range("w8:x8").ClearContents 'sequence label display
                Call Module1.Race_Time(Racename, ShtMarker, mySeqRow)
                'returns = "AAAA" which intiates sequence control in MyBets Sequence Controllers
            End If
        End If            '<==== Handling on t1
    End If
Next c
'>>>>>>>>>>>>>>>>>
Application.ScreenUpdating = True
ThisWorkbook.Worksheets.Application.Calculation = xlCalculationAutomatic: ThisWorkbook.Worksheets.Application.EnableEvents = True
End Sub

/

Countdown timer in D11 is copied upto A1 ...... except nothing is happening in cell A1 when BA is linked to this sheet.

I put the debugger against :-

Code: Select all
If (Target.Worksheet.name <> "Mkt-1") Then Exit Sub


no response, ie did not stop the code here - because it isnt getting there ?? ! most puzzling...

I tried modifying :-

Code: Select all
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


to

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


so more consistent with procedure codes on this forum - still no response in cell A1
Fixador
 
Posts: 322
Joined: Mon Apr 23, 2007 9:24 am

Severe attack of coughing and spluttering into my coffee....

Postby Fixador » Tue Dec 03, 2013 4:06 pm

I really wasn't using

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


honestly

I 'knew' it should have been

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Fixador
 
Posts: 322
Joined: Mon Apr 23, 2007 9:24 am


Return to Discussion

Who is online

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