Accumulating data in one cell

Please post any questions regarding the program here.

Moderator: 2020vision

Accumulating data in one cell

Postby dealbanker » Fri Jun 21, 2013 10:42 am

Hello

Has anyone had any experience in code to keep a running total of a cell's changing data?

The cells in column AD5:AD35 contain data as a result of calculations that give me a % number for each runner. These % numbers will/may change for each cell in that column every 3 seconds.

I am trying to find a way to have each cell's data in that column to add the data that appears every 3 seconds, into their adjacent cells (AE5:AE35).

That is, the number that appears in a cell in the AD column will add to the adjacent cell in the AE column that has a running/cumulative total figure for the AD cell.

Any ideas will be helpful

Thanks
Dealer
dealbanker
 
Posts: 63
Joined: Wed Oct 26, 2011 1:12 pm

Postby Captain Sensible » Fri Jun 21, 2013 2:40 pm

Use a bit of VBA, try this or just add the code to any existing VBA on your sheet

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Columns.Count <> 16 Then Exit Sub


Application.EnableEvents = False
Application.Calculation = xlCalculationManual

Range("AE5:AE35").Value = Range("AD5:AD35").Value



Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End Sub
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Fri Jun 21, 2013 3:01 pm

Missed the fact you wanted to accumulate totals maybe try something like this or similar, in the middle of Ascot atm, I'm guessing your refresh is set to 3 seconds otherwise you'd need to add in some timer routine

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Integer
Dim iCol As Integer
Dim cell As Object


For Each cell In Target
iRow = cell.Row
iCol = cell.Column



If iCol = 15 And iRow > 4 And iRow < 36 Then


Range("AE" & iRow).Value = Range("Y" & iRow).Value + Range("AE" & iRow).Value


Application.EnableEvents = True
End If



Next cell

End Sub
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby Captain Sensible » Fri Jun 21, 2013 3:02 pm

Ooops pasted the wrong code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim iRow As Integer
Dim iCol As Integer
Dim cell As Object


For Each cell In Target
iRow = cell.Row
iCol = cell.Column



If iCol = 15 And iRow > 4 And iRow < 36 Then
If IsEmpty(Range("AE" & iRow).Value) Then Range("AE" & iRow).Value = 0
If IsEmpty(Range("AD" & iRow).Value) Then Range("AD" & iRow).Value = 0

Range("AE" & iRow).Value = Range("AD" & iRow).Value + Range("AE" & iRow).Value


Application.EnableEvents = True
End If



Next cell

End Sub
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby dealbanker » Fri Jun 21, 2013 10:55 pm

Thanks Captain

Sorry, yes GRUSS is set to 3 sec refresh.

I pasted this code in but can not log to excel from GRUSS since I did it. It opens the workbook but does not allow me to open a worksheet, just blank.

I already have a time change based code in this worksheet that you were good enough to help with last year. Is it possible that they are conflicting, both being time change codes?

regards
Dealer
dealbanker
 
Posts: 63
Joined: Wed Oct 26, 2011 1:12 pm

Postby Captain Sensible » Sat Jun 22, 2013 3:47 pm

Possibly, if you already have a Worksheet_Change routine you'd just need to add the coding into the existing one.
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby dealbanker » Sat Jun 22, 2013 11:23 pm

Got it and done, thanks Captain
Working a treat
dealbanker
 
Posts: 63
Joined: Wed Oct 26, 2011 1:12 pm


Return to Help

Who is online

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