View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
skatonni via OfficeKB.com skatonni via OfficeKB.com is offline
external usenet poster
 
Posts: 23
Default How to create a custom function

Marcie

This will get you what you want:

Function LetterGrade(TotalPossible, TotalPoints)
Dim gradePer As Double

gradePer = TotalPoints / TotalPossible * 100

If gradePer = 90 Then
LetterGrade = "A"
ElseIf gradePer = 80 Then
LetterGrade = "B"
ElseIf gradePer = 70 Then
LetterGrade = "C"
ElseIf gradePer = 60 Then
LetterGrade = "D"
Else
LetterGrade = "F"
End If

End Function


You can save time by not calculating the percentage.

Function LetterGrade2(TotalPossible, TotalPoints)
Dim gradePer As Double

gradePer = TotalPoints / TotalPossible

If gradePer = 0.9 Then
LetterGrade2 = "A"
ElseIf gradePer = 0.8 Then
LetterGrade2 = "B"
ElseIf gradePer = 0.7 Then
LetterGrade2 = "C"
ElseIf gradePer = 0.6 Then
LetterGrade2 = "D"
Else
LetterGrade2 = "F"
End If

End Function


Marcie wrote:
Steve, thank you but how do I write "If the percentage of TotalPoints
etc...." when I type "If percentage of total..." I cant use the word
percentage in my formula. do you know how I can get it to work? Do I need
to type something defining percentage of total?
Thanks

Marcie,

[quoted text clipped - 22 lines]
thank you,
Marcie


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200608/1