Converting calculation to a grade

Krayna

New Member
Joined
Feb 2, 2021
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi, I am quite new to VB in Excel.
I would like to write a function which converts any given percentage into a grade following the grade system defined (this would vary depending on class so would I define table first?)
I have tried mathematically working this out using ratios/percentages but could not think of a straightforward method to do this...
Would appreciate any ideas.

Sample conversion rates:
0 - 0%
1.0 - 45%
1.6 - 65%
2.3 - 75%
3.1 - 85%
3.7 - 100%
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Welcome to the forum!

You can do this on the worksheet like this:

Book1
DEFGHI
1PercentGradeGradePercentGrade
20%0.000%0
333%0.0045%1
464%1.0165%1.6
565%1.61.675%2.3
666%1.61.685%3.1
792%3.13.1100%3.7
8100%3.73.7
Sheet3
Cell Formulas
RangeFormula
E2:E8E2=LOOKUP(D2,{0,0.45,0.65,0.75,0.85,1},{0,1,1.6,2.3,3.1,3.7})
F2:F8F2=VLOOKUP(D2,$H$2:$I$7,2)


The E2 formula has the table built into it, the F2 formula uses the H1:I7 table, so you can change it as desired.

If you're looking for a VBA solution, you can use either of these formulas in the EVALUATE function. There are also native VBA methods you can use. Let us know exactly what you're looking for.
 
Upvote 0
Okay that does solve part of my query.
However the grades to be converted must find the grade to the closest decimal point the ones I provided are a guide of the boundaries.
For example, 55% would be 1.3

How to implement this on spreadsheet?
 
Upvote 0
Here is one idea. The FORECAST/OFFSET part gives an error when the input percentage matches the last lookup entry. To fix this, I added an initial check in the formula, but there may be a more elegant way.
Book1
DEFGHI
1PercentGradePercentGrade
200.0000
30.330.730.451
40.641.570.651.6
50.651.600.752.3
60.661.670.853.1
70.923.3813.7
813.70
90.551.30
Krayn
Cell Formulas
RangeFormula
E2:E9E2=IF(D2=$H$7,$I$7,FORECAST(D2,OFFSET($I$2:$I$7,MATCH(D2,$H$2:$H$7,1)-1,0,2), OFFSET($H$2:$H$7,MATCH(D2,$H$2:$H$7,1)-1,0,2)))
 
Upvote 0
Solution
Sure, you could use:

=IFERROR(FORECAST(D2,OFFSET($I$2:$I$7,MATCH(D2,$H$2:$H$7,1)-1,0,2), OFFSET($H$2:$H$7,MATCH(D2,$H$2:$H$7,1)-1,0,2)),$I$7)

but it's sort of a wash as to which is better. Kirk's version might be better because if you have a non-numeric value in D2, his would create an actual error code, but the IFERROR version would just put the maximum value in it.
 
Upvote 0
Sorry...I missed the notification from earlier today. Eric is spot on. You could use the IFERROR wrapping, but be aware of its behavior. I wasn't sure how you wanted to treat: 1) blank cells (giving a result of 0), 2) errant text inputs (resulting in a #VALUE! error), and 3) errant values that fall outside the range specified in the lookup table (producing either a #N/A or #DIV/0! error). If you're reasonably confident that these things won't become issues and the only likely snag might be when the input percentage matches the upper bound of the lookup table, then the IFERROR wrapping shown by Eric might be preferred.
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,288
Members
448,885
Latest member
LokiSonic

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top