macro to clear range of cells

Please post any questions regarding the program here.

Moderator: 2020vision

macro to clear range of cells

Postby nhmaster » Fri Feb 15, 2008 6:36 pm

Hello

Sure this request is pretty simple, can anyone create a VBA code macro that will clear cells T5, U5,V5,W5 if cells AB15 = 2, it needs to be running continuously, it will be clearing bet refs etc to enable additional triggers to fire. Be much appreciated if anyone can help or send me a private message

Cheers Shaun
User avatar
nhmaster
 
Posts: 29
Joined: Sat Nov 19, 2005 8:49 am
Location: Tenerife

Postby phrenetic » Sat Feb 16, 2008 11:26 am

Shaun

Try this (typed in directly so not tested!):

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("Sheet1")
 
  ' Stop any further updates until we have completed
  Application.EnableEvents = False
 
  ' Check for 2 in cell AB15
  If ws1.Range("AB15").Value = 2 Then
     ' Clear bet references
     ws1.Range("T5:W5").ClearContents
  End If
 
  ' Re-enable updates
  Application.EnableEvents = True
 End Sub


Alistair
phrenetic
 
Posts: 142
Joined: Tue Oct 16, 2007 8:44 pm

Postby nhmaster » Sat Feb 16, 2008 12:12 pm

Hello alistar

Thanks for that, just to check I do it right, if I copy and paste the code into where exactly. I have opened visual basic with the spreadsheet open and am presented with list of sheets 1/3 my worksheet is sheet 1 so I click that, I have 2 dropdown boxes at top of sheet what do I select GENERAL or WORKSHEET

Many thanks in advance
User avatar
nhmaster
 
Posts: 29
Joined: Sat Nov 19, 2005 8:49 am
Location: Tenerife

Postby Ian » Sat Feb 16, 2008 2:29 pm

WORKSHEET
Ian
 
Posts: 834
Joined: Sat Nov 19, 2005 8:35 am
Location: Birmingham

Postby phrenetic » Sat Feb 16, 2008 4:52 pm

From the spreadsheet, choose the tab that you want, right click and select view code.

Paste the code into the empty area that opens up (on the right hand side of the list of sheets, etc).

Alistair
phrenetic
 
Posts: 142
Joined: Tue Oct 16, 2007 8:44 pm


Return to Help

Who is online

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