VBA clear code

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

Moderator: 2020vision

VBA clear code

Postby Shaun » Wed Nov 26, 2008 1:58 am

Hi all.

I am trying to get this code to work

Code: Select all
Option Explicit

Dim wb1 As Workbook
Dim ws1 As Worksheet

Private Sub Worksheet_Change(ByVal Target As Range)
  ' Only process whole updates
  If Target.Columns.Count <> 16 Then Exit Sub
 
  ' Set-up workbook variables
  Set wb1 = ThisWorkbook
  Set ws1 = wb1.Sheets("Results")
 
  ' Stop any further updates until we have completed
  Application.EnableEvents = False
 
  ' Check for 2 in cell H1
  If ws1.Range("H1").Value = 2 Then
     ' Clear bet references
     ws1.Range("A2:f12").ClearContents
  End If
 
  ' Re-enable updates
  Application.EnableEvents = True
 End Sub


What i need it to do is every time a result is known i have a fomula on "Results" that checks if it won or lost if i get 2 losses in a row i need the vba code to clear the list of results so i can start again.
Shaun
 
Posts: 435
Joined: Fri May 09, 2008 11:11 pm
Location: Kellerberrin, Western Australia

Postby dgs2001 » Wed Nov 26, 2008 8:06 am

Shaun
Your problem may be the
Code: Select all
 Private Sub Worksheet_Change(ByVal Target As Range)
  ' Only process whole updates
  If Target.Columns.Count <> 16 Then Exit Sub
 


This tells the code to only run if 16 columns of info has changed on your sheet.
If there is other code already in the change event then you could put your code in a worksheet calculate event instead.

Duncan
User avatar
dgs2001
 
Posts: 334
Joined: Thu Apr 05, 2007 4:53 pm
Location: The Home Of National Hunt

Postby Roger » Wed Nov 26, 2008 9:22 am

Shaun, the test for target columns count being 16 is for the prices refresh sheet code. On the Results sheet, you won't have that many columns ever, so you need to take that test out.
Roger
 
Posts: 140
Joined: Fri Nov 18, 2005 10:45 pm


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.