#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.misc
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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 79
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 449
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing UDF Help jlclyde Excel Discussion (Misc queries) 4 April 22nd 08 08:30 PM
Writing IF Statement Angie Excel Worksheet Functions 4 June 5th 07 10:10 PM
q; Writing to files JIM.H. Excel Discussion (Misc queries) 1 April 23rd 07 10:36 PM
Writing to csv Jeff Excel Discussion (Misc queries) 2 March 16th 07 01:35 PM
Need help writing formula plz.. nparrott Excel Discussion (Misc queries) 7 February 10th 06 05:26 PM


All times are GMT +1. The time now is 06:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"