My crude VBA attempt to record race data gives an error 1004

Please post any questions regarding the program here.

Moderator: 2020vision

My crude VBA attempt to record race data gives an error 1004

Postby xraymitch » Thu Jan 17, 2019 5:56 pm

I am trying to learn VBA and any help from the good folks here with VBA skills is much appreciated. :)

I am Logging Current Prices into multiple sheets and Auto Selecting markets 15 minutes before the off.

This is the code I have in Sheets 1, 3, 5 and 7:

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Columns.Count = 16 Then

Application.EnableEvents = False

If (Cells(2, 5) = "In Play" And Cells(2, 6) = "") And Cells(1, 20) = 1 Then Call Dummy

If Cells(2, 5) = "Not In Play" And Cells(2, 6) = "" Then Cells(1, 20) = 1

If Cells(2, 5) = "In Play" And Cells(2, 6) = "" Then
If Cells(1, 24) = "" Then Cells(1, 24) = Cells(2, 3)
If Cells(1, 24) <> "" Then Cells(2, 24) = DateDiff("s", Cells(1, 24), Cells(2, 3))
End If

If Cells(2, 5) <> "In Play" And Cells(2, 6) <> "Suspended" Then
Cells(1, 24) = ""
Cells(2, 24) = ""
Cells(1, 26) = ""
End If

If (Cells(2, 5) = "In Play" And Cells(2, 6) = "Suspended") And Cells(1, 26) = "" Then

Range("W1:AH1").Select
Selection.Copy
Range("W1").Activate
ActiveCell.Offset(Cells(1, 27), 23).Activate
ActiveCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Range("Q1").Select
Application.CutCopyMode = False
Cells(1, 26) = 1
Cells(1, 27) = Cells(1, 27) + 1
End If


Application.EnableEvents = True



End If

End Sub

This is the code I have in the Module 1:

Sub Dummy()

If Cells(2, 5) = "In Play" And Cells(5, 34) <= -1.01 Then Cells(5, 20) = "DUMMY"

Cells(1, 20) = 2

End Sub

If only one Market is active then the Range("W1:AH1") containing the race data will get get copied as you can see from the screenshot below

Screenshot Excel.png
Screenshot Excel.png (171.04 KiB) Viewed 5731 times


If more than one market is active I get the following error as you can see from the screenshot below

Error 1004.png
Error 1004.png (13 KiB) Viewed 5731 times
xraymitch
 
Posts: 410
Joined: Wed Jun 25, 2008 7:06 am
Location: UK

Re: My crude VBA attempt to record race data gives an error

Postby xraymitch » Thu Jan 17, 2019 6:00 pm

Sorry forgot to add this screenshot showing the Sheets and Module 1

EXCEL_2019-01-17_15-01-12.png
EXCEL_2019-01-17_15-01-12.png (119.59 KiB) Viewed 5730 times
xraymitch
 
Posts: 410
Joined: Wed Jun 25, 2008 7:06 am
Location: UK


Return to Help

Who is online

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