Here you go: I had to add an IF statement within the Do While Loop because their would be an error generated by the code trying to look before row 1. I also changed the While-Wend function with a Do While Loop in order to be able to get out of it with the Exit Do command which is impossible for the While-Wend function.
Sub NewSessionNumber()
Application.ScreenUpdating = False
ActiveWorkbook.Sheets("Sheet1").Select
'this line find the last row with data
Range("A" & Cells(Rows.Count, 1).End(xlUp).Row).Select
'If players are the same.
If ActiveCell.Value = ActiveCell.Offset(-1, 0) Then
'If Match Number is less than 10.
If ActiveCell.Offset(-1, 1).Value < 10 Then
ActiveCell.Offset(0, 1) = ActiveCell.Offset(-1, 1) + 1
ActiveCell.Offset(0, 2) = ActiveCell.Offset(-1, 2)
Else 'If Match Number is 10.
ActiveCell.Offset(0, 1) = 1
ActiveCell.Offset(0, 2) = ActiveCell.Offset(-1, 2) + 1
End If
'
Else 'If Players are not the same.
i = 1
'this search for the last occurence of the name from the bottom up
Do While ActiveCell <> ActiveCell.Offset(-i, 0)
i = i + 1
If i = ActiveCell.Row - 1 Then GoTo New_player
Loop
'If Match Number is less than 10.
If ActiveCell.Offset(-i, 1).Value < 10 Then
ActiveCell.Offset(0, 1) = ActiveCell.Offset(-i, 1) + 1
ActiveCell.Offset(0, 2) = ActiveCell.Offset(-i, 2)
Else 'If Match Number is 10.
ActiveCell.Offset(0, 1) = 1
ActiveCell.Offset(0, 2) = ActiveCell.Offset(-i, 2) + 1
End If
End If
GoTo E_nd
New_player:
ActiveCell.Offset(0, 1) = 1
ActiveCell.Offset(0, 2) = 1
E_nd:
Application.ScreenUpdating = True
End Sub
Bookmarks