Writing a UDF

H

Hajiki

I used this (see below) UDF successfully (can't believe it) but now I want to
do te opposite where 15 =A+, no idea how to write it!

Function Grades(Letter As String) As Integer
Select Case Letter
Case Is = "A+"
Grades = 15
Case Is = "A"
Grades = 14
Case Is = "A-"
Grades = 13
Case Is = "B+"
Grades = 12
Case Is = "B"
Grades = 11
Case Is = "B-"
Grades = 10
Case Is = "C+"
Grades = 9
Case Is = "C"
Grades = 8
Case Is = "C-"
Grades = 7
Case Is = "D+"
Grades = 6
Case Is = "D"
Grades = 5
Case Is = "D-"
Grades = 4
Case Is = "F+"
Grades = 3
Case Is = "F"
Grades = 2
Case Is = "F-"
Grades = 1
End Select
End Function
 
P

Pete_UK

You don't really need a UDF - you can set up a table somewhere
consisting of the grade numbers and the grade letters (for example in
X1:Y15 and looking like this:

15 A+
14 A
13 A-
12 B+

and so on, and then use this formula:

=VLOOKUP(A1,X$1:Y$15,2,0)

to get the grade letters from a grade number in A1 (for example).

You could use the same table with an INDEX/MATCH combination instead
of your UDF.

Hope this helps.

Pete
 
H

Harald Staff

Gentlemen, this is a question of symmetry and style,"don't have to" is not
an issue ;-)

Function GradeLetter(Grade as Integer) as String
Select case Grade
Case 1
GradeLetter = "H--"
Case 2
GradeLetter = "To be shot"
Case 3
GradeLetter = "Aww"

... and so on
Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top