A couple of small problems

n107jkx

Board Regular
Joined
Dec 3, 2002
Messages
51
I am trying to use a module to convert a grade into a numeric value. I am using the code as below and I have already used similar coding to convert a mark number into a grade. As i am a novice in using VBA, i would be grateful if anybody could point out where i am going wrong.

Function ConvertGrade(ScoreIn As Variant)
Select Case ScoreIn
Case Is = A
ConvertGrade = "6"
Case Is = AB
ConvertGrade = "5.5"
Case Is = B
ConvertGrade = "5"
Case Is = BC
ConvertGrade = "4.5"
Case Is = C
ConvertGrade = "4"
Case Is = CD
ConvertGrade = "3.5"
Case Is = D
ConvertGrade = "3"
Case Is = DE
ConvertGrade = "2.5"
Case Is = E
ConvertGrade = "2"
Case Is = U
ConvertGrade = "1"
End Select
End Function

Also, can anybody recommend the best way to create a scatter graph in Access.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You need to surround your grades in " marks, otherwise VBA will interpret them as being variables e.g.

Code:
Function ConvertGrade(ScoreIn As Variant)
Select Case ScoreIn
Case Is = "A"
ConvertGrade = "6"
Case Is = "AB"
ConvertGrade = "5.5"
Case Is = "B"
ConvertGrade = "5"
Case Is = "BC"
ConvertGrade = "4.5"
Case Is = "C"
ConvertGrade = "4"
Case Is = "CD"
ConvertGrade = "3.5"
Case Is = "D"
ConvertGrade = "3"
Case Is = "DE"
ConvertGrade = "2.5"
Case Is = "E"
ConvertGrade = "2"
Case Is = "U"
ConvertGrade = "1"
End Select
End Function

Also, if the numeric grade is going to be used in any sort of calculation e.g. averaging of grades then you're probably best off removing the " from the numbers e.g.

Case Is = "U"
ConvertGrade = 1
 
Upvote 0

Forum statistics

Threads
1,221,618
Messages
6,160,853
Members
451,674
Latest member
TJPsmt

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