I have 3 columns in my excel file: Name, Percentage, and Grade.
I want to automate the letter grade (e.g. percent of 95 will generate "A") to populate in the third column until the last row.
I keep getting an error related to how I loop this code. Any insight?
Sub Grades()
Dim score As Integer
Dim x As Integer
x = 1
score = Sheets("sheet1").Cells(x, 2).Value
Do While score <> ""
If score >= 90 And score <= 100 Then
Sheets("Sheet1").Cells(x, 3).Value = "A"
ElseIf score > 79 And score < 90 Then
Sheets("Sheet1").Cells(x, 3).Value = "B"
ElseIf score > 69 And score < 80 Then
Sheets("Sheet1").Cells(x, 3).Value = "C"
ElseIf score > 59 And score < 70 Then
Sheets("Sheet1").Cells(x, 3).Value = "D"
ElseIf score < 60 Then
Sheets("Sheet1").Cells(x, 3).Value = "F"
Else
Sheets("Sheet1").Cells(x, 3).Value = ""
End If
x = x + 1
score = Sheets("sheet1").Cells(x, 2).Value
Loop
Select Casewould be better IMHO.