Sub CalculateSkills()
Dim cell As Range
Dim mRow As Integer
Dim teamA As String
Dim teamB As String
Dim teamAscore As String
Dim teamBscore As String
Dim teamAskill As String
Dim teamBskill As String
Dim teamAwins As Boolean
Dim teamAposition As Integer
Dim teamBposition As Integer
Dim skilldifference As Integer
For Each cell In Range("Games!A2:A9")
mRow = cell.Row
teamA = Sheets("Games").Cells(mRow, 1)
teamB = Sheets("Games").Cells(mRow, 2)
teamAscore = Sheets("Games").Cells(mRow, 3)
teamBscore = Sheets("Games").Cells(mRow, 4)
teamAwins = Val(teamAscore) > Val(teamBscore)
teamAposition = Range("Rankings!B2:B9").Find(teamA).Row
teamBposition = Range("Rankings!B2:B9").Find(teamB).Row
teamAskill = Sheets("Rankings").Cells(teamAposition, 3)
teamBskill = Sheets("Rankings").Cells(teamBposition, 3)
If teamAwins Then
skilldifference = Int(teamBskill / 5)
teamAskill = teamAskill + skilldifference
teamBskill = teamBskill - skilldifference
Else
skilldifference = Int(teamAskill / 5)
teamAskill = teamAskill - skilldifference
teamBskill = teamBskill + skilldifference
End If
Sheets("Rankings").Cells(teamAposition, 3) = teamAskill
Sheets("Rankings").Cells(teamBposition, 3) = teamBskill
Sheets("Rankings").Cells(teamAposition, 4) = _
Sheets("Rankings").Cells(teamAposition, 4) + teamAscore
Sheets("Rankings").Cells(teamAposition, 5) = _
Sheets("Rankings").Cells(teamAposition, 5) + 1
Sheets("Rankings").Cells(teamBposition, 4) = _
Sheets("Rankings").Cells(teamBposition, 4) + teamBscore
Sheets("Rankings").Cells(teamBposition, 5) = _
Sheets("Rankings").Cells(teamBposition, 5) + 1
Next cell
Range("A2:E9").Sort Key1:=Range("C2:C9"), Order1:=xlDescending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
Sub PredictScore()
Dim cell As Range
Dim mRow As Integer
Dim teamA As String
Dim teamB As String
For Each cell In Range("Predict!A2:A4")
mRow = cell.Row
teamA = Sheets("Predict").Cells(mRow, 1)
teamB = Sheets("Predict").Cells(mRow, 2)
teamAposition = Range("Rankings!B2:B9").Find(teamA).Row
teamBposition = Range("Rankings!B2:B9").Find(teamB).Row
teamAskill = Sheets("Rankings").Cells(teamAposition, 3)
teamBskill = Sheets("Rankings").Cells(teamBposition, 3)
teamAwins = Val(teamAskill) > Val(teamBskill)
If teamAwins Then
teamBscore = Int(Sheets("Rankings").Cells(teamBposition, 4) / _
Sheets("Rankings").Cells(teamBposition, 5))
teamAscore = Int(teamBscore * (teamAskill / teamBskill))
Else
teamAscore = Int(Sheets("Rankings").Cells(teamAposition, 4) / _
Sheets("Rankings").Cells(teamAposition, 5))
teamBscore = Int(teamAscore * (teamBskill / teamAskill))
End If
Sheets("Predict").Cells(mRow, 3) = teamAscore
Sheets("Predict").Cells(mRow, 4) = teamBscore
Next cell
End Sub