I am trying to pull numerical grade values and convert them into a string which will represent the grade, A >90, B >80, and so on. I planned to use a for loop to gather the values from the spreadsheet and then if then statements to assign the letter designation. Here is the code I have so far.
For i = 1 To 11
' Pull Grade numerical value
Grade = Cells(2 + i, 16).Value
' Assign Numerical Value a script Grade
If Grade > 60 Then
Letter = "D"
If Grade > 70 Then
Letter = "C"
If Grade > 80 Then
Letter = "B"
If Grade > 90 Then
Letter = "A"
Else
Letter = "F"
Exit
' Print the letter grade
Cells(2 + i, 17).Text = Letter
Next i
I keep getting errors either pertaining to "Exit" or to "Next i". I have tried using "End" statements as well but that didn't fix the problems either.
Or just use a formula in column Q:
=IF(P:P>=90,"A",IF(P:P>=80,"B",IF(P:P>=70,"C",IF(P:P>=60,"D","F"))))
so it updates automatically and you don't need to use VBA.
Alternatively you can add a sheet named GradeList
with the following data
and use
=INDEX(GradeList!B:B,MATCH(P:P,GradeList!A:A,1))
as formula. This way you can easily edit the numbers/grades later, and it will pick the correct grades automatically:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With