Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Writing a UDF
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Writing a UDF
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 Rather than using a UDF have you considered a LOOOKUP array instead: =LOOKUP(A1,{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 ;"F-","F","F+","D-","D", "D+","C-","C","C+","B-","B","B+","A-","A","A+","RE-ENTER DATA"}) this error checks for scores over 15 where the score is in A1 - you can drag down edvwvw -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...excel/200806/1 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Writing a UDF
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 "Hajiki" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Writing UDF Help | Excel Discussion (Misc queries) | |||
Writing IF Statement | Excel Worksheet Functions | |||
q; Writing to files | Excel Discussion (Misc queries) | |||
Writing to csv | Excel Discussion (Misc queries) | |||
Need help writing formula plz.. | Excel Discussion (Misc queries) |