Thread: Writing a UDF
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default Writing a UDF

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

On Jun 16, 11:40*am, Hajiki wrote:
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