Place Bets VBA

Please post any questions regarding the program here.

Moderator: 2020vision

Place Bets VBA

Postby jrarmstrong » Sun Apr 22, 2012 8:45 pm

Hi,

I have written a simple macro to insert text (a "1") into the bet ref column to use the CANCEL-ALL trigger in the Place Bets sheet. When the conditions are met the macro fires but the CPU goes crazy making my PC run slowly.

Presumably this is because my code wants to keep inserting a 1 into the bet ref column and the existing code wants to clear it?

I had hoped adding the following line into the existing code would sort this out but I just get a "Type Mismatch" Runtime Error 13 message. Can anyone see where I am going wrong?

If Cells(R, 17) = "1" Then Exit Sub

Thanks,

James


Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim selecRow As Integer
    If Target.Columns.Count = 16 Then
        Application.EnableEvents = False
        For R = 5 To 55
            If Cells(R, 17) = "1" Then Exit Sub       
              If Cells(R, 28) > 0 Then
                If Cells(R, 20) <> "" And Cells(R, 20) <> "PENDING" Then
                    selecRow = Cells(R, 28) + 1
                    If ThisWorkbook.Sheets("Selections").Cells(selecRow, 10) = "" Then
                        ThisWorkbook.Sheets("Selections").Cells(selecRow, 10) = Cells(R, 20)
                        Cells(R, 20) = ""
                    End If
                End If
            End If
        Next
        Application.EnableEvents = True
    End If
End Sub
Code: Select all
jrarmstrong
 
Posts: 54
Joined: Fri Sep 23, 2011 6:27 pm

Postby jrarmstrong » Sun May 13, 2012 8:23 pm

Hi,

I've been struggling to resolve this error. The following is intended to achieve the same result but still just gives me the same error message. Can anyone point out what is wrong?

Thanks,

James

Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Dim selecRow As Integer
If Target.Columns.Count = 16 Then
    If Range("Q5").Value <> "CANCEL" Then
        Application.EnableEvents = False
        For R = 5 To 55
            If Cells(R, 28) > 0 Then
                If Cells(R, 20) <> "" And Cells(R, 20) <> "PENDING" Then
                    selecRow = Cells(R, 28) + 1
                    If ThisWorkbook.Sheets("Stock").Cells(selecRow, 10) = "" Then
                        ThisWorkbook.Sheets("Stock").Cells(selecRow, 10) = Cells(R, 20)
                        Cells(R, 20) = ""
                    End If
                End If
            End If
        Next
        Application.EnableEvents = True
    Else
        Call Cancel
    End If
End If
End Sub
jrarmstrong
 
Posts: 54
Joined: Fri Sep 23, 2011 6:27 pm

Postby alrodopial » Sun May 13, 2012 8:51 pm

The "" that you are inserting with the
Code: Select all
Cells(R, 20) = ""
is different than an empty cell.
Use the
Code: Select all
Cells(R, 20).ClearContents
alrodopial
 
Posts: 1384
Joined: Wed Dec 06, 2006 9:59 pm

Postby jrarmstrong » Thu May 17, 2012 10:13 pm

Thanks alrodopial I'll try it out.

James
jrarmstrong
 
Posts: 54
Joined: Fri Sep 23, 2011 6:27 pm


Return to Help

Who is online

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