I'm still a newbie at this but I am trying to build a VB Macro to provide me with the Average Bet Value per session. Basically I have a list of Dates in Cell 'AD' and also a list of Bet Values in Cell 'AE'.
I am finding a difficulty in coding VB to calculate :
From Col 'AD' which contains the dates I need to loop through the dates and if there is a 10 minute difference between a date and an other, then both dates will be considered as a start and end date.
Following Step number 1. I need to get the Bet values which fall between the Start and End date and get the average of that session in Col 'AF'
Last but not least I need to do this process for all the dates in Col 'AD' - for every session identified we get the average bet value in col AF'
I have pasted the code on how I generated Col AD and Col AE and a snip of the data I am using.
I hope i explained myself well and would like to thank you all
Public Sub GetDebitValue()
RowCounter = 1
Profile.Range("AE1").Value = "BET VALUE"
Profile.Range("AD1").Value = "BET TIME AND DATE"
Profile.Range("AF1").Value = "SESSION BET AVERAGE"
'Range Col 'H2' Contained the action types called Debit which are considered as bets - if value is debit take the bet amount from Col 'C'
If Profile.Range("H2").Value = "debit" Then
Profile.Range("C2" + CStr(RowCounter + 1)).Value = Profile.Range("C2" + CStr(RowCounter)).Value
'Set Date
Profile.Range("AD2").Value = Profile.Range("I2").Value
'Set Value
Profile.Range("AE2").Value = Profile.Range("C2").Value
End If
'Always start with debit
Do
Select Case Profile.Range("H" + CStr(RowCounter)).Value
Case "debit"
Profile.Range("AE" + CStr(RowCounter + 1)).Value = Profile.Range("C" + CStr(RowCounter)).Value
'Copy Date
Profile.Range("AD" + CStr(RowCounter + 1)).Value = Profile.Range("I" + CStr(RowCounter)).Value
Case Else
'Do Nothing
End Select
If Profile.Range("A" + CStr(RowCounter + 1)).Value = CStr("") Then
Exit Do
End If
'Call GamblingLength
RowCounter = RowCounter + 1
Loop Until RowCounter = 99999
End Sub
