Before this is ran please ensure your data is sorted first by ID, then by the Term. Also make sure your data tab is named Data as this is what it is looking for in the code.
Next you will need to add a fourth column called Weight to your data converting your Grades to a numeric value representing its Weight. I made a VLOOKUP function where A would show as 13, A- as 12, B+ as 11, etc. up until W as 1. You will want these on a separate tab as we will be deleting rows from the first data and it will break the VLOOKUP weights if they get deleted.
Once you have your formula, copy it down all of your data so each row contains the grade's corresponding numeric weight.
Here is how the data should look: http://imgur.com/cfVZdwq
Finally, this VBA will do the rest of the work.
Public Sub Sort_Grades_Data()
Dim data As Worksheet
Set data = VBAProject.ThisWorkbook.Worksheets("Data") ' Worksheet containing data
ID = 1 ' column ID is in
Grade = 3 ' column Grade is in
Weight = 4 ' column with vlookups converting grades to numeric weight
crow = 2 ' first line of actual data (not headers)
While Len(data.Cells(crow, ID).Value) > 0
If data.Cells(crow + 1, ID).Value = data.Cells(crow, ID).Value Then ' Check if the next line is the same ID
If data.Cells(crow + 1, Weight).Value >= data.Cells(crow, Weight).Value Then
data.Rows(crow).EntireRow.Delete ' next row has greater or same weight so delete the current row
crow = crow - 1 ' since we deleted a row, we have to go back one step
ElseIf data.Cells(crow + 1, Weight).Value < data.Cells(crow, Weight) Then
data.Rows(crow & ":" & crow + 1).Interior.Color = RGB(255, 255, 0) ' Set rows to yellow
End If
End If
crow = crow + 1 ' move to the next line of data
Wend
End Sub
Let me know if you have any questions.