# Assigning letter grades to student roster

#### vanduo

##### New Member
I am teaching large classes and after each test I need to assign letter grades to students’ test scores. Could someone help me out please in writing a macro to do so? Thank you very much.

If student’s score is from 100 to 90 then A
If student’s score is from 89 to 80 then B
If student’s score is from 79 to 70 then C
If student’s score is from 69 to 60 then D
If student’s score is equal to or less then 59 then F

Arunas Juska
East Carolina University

### Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
if you can get away with a formula, you could use
=IF(LEN(A1),VLOOKUP(A1,{0,"f";60,"d";70,"c";80,"b";90,"a"},2),"")
=IF(LEN(A1),VLOOKUP(A1,{0,"f";.6,"d";0.7,"c";0.8,"b";0.9,"a"},2),"")

No need for a macro. The VLOOKUP function was desiged for this type of problem. See Example.
Book1
ABCDEFG
2John78C0F
3Mary85B60D
4Bill93A70C
5Sue58F80B
690A
7
...

This message was edited by lenze on 2002-10-08 15:23

On 2002-10-08 15:10, vanduo wrote:
I am teaching large classes and after each test I need to assign letter grades to students’ test scores. Could someone help me out please in writing a macro to do so? Thank you very much.

If student’s score is from 100 to 90 then A
If student’s score is from 89 to 80 then B
If student’s score is from 79 to 70 then C
If student’s score is from 69 to 60 then D
If student’s score is equal to or less then 59 then F

Arunas Juska
East Carolina University

One solution is to just use a Lookup

=LOOKUP(A2,{0,60,70,80,90;"F","D","C","B","A"})

or edit the following
'ensure correct results are are thresholds
' may have to adjust ranges such as .9 to .929
Case Is > 0.97: LetterGrade = "A+"
Case 0.93 To 0.97: LetterGrade = "A"
Case 0.9 To 0.93: LetterGrade = "A-"
Case 0.87 To 0.9: LetterGrade = "B+"
Case 0.83 To 0.87: LetterGrade = "B"
Case 0.8 To 0.83: LetterGrade = "B-"
Case 0.77 To 0.8: LetterGrade = "C+"
Case 0.73 To 0.77: LetterGrade = "C"
Case 0.7 To 0.73: LetterGrade = "C-"
Case 0.67 To 0.7: LetterGrade = "D+"
Case 0.63 To 0.67: LetterGrade = "D"
Case 0.6 To 0.63: LetterGrade = "D-"
End Select
End Function

Also possible with a formula.
If the scores are in column A (the first in A2), put in B2:

=IF(ISNUMBER(A2)=FALSE,"",IF(A2<=59,"F",IF(A2<70,"D",IF(A2<80,"C",IF(A2<90,"B","A"))))

and copy down in column B.

Replies
1
Views
397
Replies
4
Views
436
Replies
1
Views
120
Replies
10
Views
352
Replies
3
Views
2K

1,216,482
Messages
6,130,931
Members
449,607
Latest member
babylegs

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back