Im quite new to using VBA so this may be a simple this to resolve.
what im trying to do is update the balance/exp when needed/conditions are met.
I currently have all football markets open in the first tab/page then log them to the same sheet.
in cell S1 (and every 10th cell ie S11,S21) i have a formula that tells me if a bet has been cancelled within that market(this is needed as i normally have a lot of bets firing off and stake is based on balance...so bets get cancelled due to available balance) - Y/N, (also covers market state etc)
In cell AL1 i have a formula that counts all the 'Y's in S:S to the last market, output = 1,2,3 etc (i found i needed to do this so if there isnt a 'Y' in S1 but in S11 the macro will trigger)
The macro observes cell $AL$1, if>=1 then
look in S1 and every 10th for 'Y' then
if 'Y' it will update balance for that market by putting 'U' in the relevant 'J#' cell.
This all works perfectly, however after a few hours of running the computer becomes unresponsive/frozen. (disable macro=no problem), this has me thinking i need to flush mem/cache/whatever but like i said im new to this so may need something different.
my code:-
Module
- Code: Select all
Sub updatebalance()
Range("S1").Select
Do Until IsEmpty(Selection.Value)
If ActiveCell.Value = "Y" Then
ActiveCell.Offset(1, -9).Value = "U"
End If
ActiveCell.Offset(10, 0).Select
Loop
End Sub
Sheet1
- Code: Select all
Private Sub worksheet_change(ByVal target As Range)
If target.Columns.Count = 16 Then
Application.EnableEvents = False
With Application
.EnableEvents = False
.ScreenUpdating = False
If UCase(Me.Range("$AL$1").Value) >= 1 Then
Call updatebalance
End If
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End Sub
BA version 1.1.0.65z9c
Cheers
WBI