1

I'm using Excel 2013 and I have had to create a If statement which basically chooses a student's grade depending on a certain mark number (obviously, nesting is needed) Here is the If statement I created:

=IF(E2<=20,"N",
IF(OR(E2>=21,E2<=25),4,
    IF(OR(E2>=26,E2<=32),"5C",
        IF(OR(E2>=33,E2<=38),"5B", 
            IF(OR(E2>=39, E2<=44), "5A", 
                IF(OR(E2>=45, E2<=53), "6C", 
                    IF(OR(E2>=54, E2<=61), "6B", 
                        IF(OR(E2>=62, E2<=71), "6A", 
                            IF(OR(E2>=72, E2<=87), "7C", 
                                IF(OR(E2>=88, E2<=103), "7B", 
                                    IF(OR(E2>=104, E2<=120), "7A")))))))))))

The error I receive is:

the specified formula cannot be entered because it uses more levels of nesting than allowed in the current file format

My question is, how do I shorten this statement to allow Excel to use it?

4

5 回答 5

6

Place the logic in the spreadsheet cells. One column for the minimum score, and one column for the grade-:

       A     B 
1      0     N
2      21    4
3      26    5C
4      33    5B
5      39    5A
6      45    6C
7      54    6B
8      72    7C
9      88    7B
10    104    7A

Then do a vlookup to get the grade from the actual score. vlookup will find the highest value in the A column that is less that the lookup value of 38.

In the example vlookup below 38 is the score, A1:B10 is the lookup table 2 is the 2nd column (in this case the B column) that contains the result (the grade).

=VLOOKUP(38, A1:B3, 2, TRUE)
于 2013-05-04T13:42:27.953 回答
1

You can also use the following formula.

=LOOKUP(E2;{0;21;26;33;39;45;54;62;72;88;104;121};{"N";4;"5C";"5B";"5A";"6C";"6B";"6A";"7C";"7B";"7C";"No match"})
于 2013-05-04T14:25:34.010 回答
0

There are a few different solutions. AND agreements using OR instead of the first that comes to mind.

=IF(E2<=20,"N",
IF(AND(E2>=21,E2<=25),4,
    IF(AND(E2>=26,E2<=32),"5C", ...
于 2013-05-04T14:05:16.220 回答
0

The best way, in my opinion, is to write a UDF. Then you can use VBA and a CASE statement. Experiment with this code in VBA to create a UDF named GRADE() - just type it into a MODULE in the VBE:

Function Grade(Marks)
 Dim Score As Integer
 Score = Marks * 1
 Select Case Score
    Case 1 To 20
        Grade = "N"
    Case 21 To 50
        Grade = "C"
    Case 51 To 90
        Grade = "B"
    Case 91 To 120
        Grade = "A"
 End Select
End Function

Then use the Function GRADE() as you would any other function but type the address of the argument - like this GRADE(B7) to use it

于 2015-09-07T22:03:22.353 回答
-1
=+IF(O3="Negative","Negative",IF(P3="Negative","Negative",IF(Q3="Negative","Negative",IF(R3="Negative","Negative",IF(O3="Refer","Refer",IF(P3="Refer","Refer",IF(Q3="Refer","Refer",IF(R3="Refer","Refer","Positive"))))))))

I find the final status in 4 cells have positive,negative,refer,pending or blank

于 2016-09-28T09:08:31.357 回答