Stephen_IV
Well-known Member
- Joined
- Mar 17, 2003
- Messages
- 1,125
- Office Version
-
- 365
- 2019
- Platform
-
- Windows
Currently I am using this formula =AVERAGE(CHOOSE(MATCH(A1:E1,{"A+","A","A","B+","B","B-","C+","C","C-","D+","D","F"},0),4,3.8,3.6,3.4,3.2,3,2.8,2.6,2.4,2.2,2,0)) to calculate the GPA's and it works fine. What I am trying to do is to wite a function for GPA's and I am coming up short. I am still trying to learn VBA can someone please guide me. Thanks in advance Stephen.
Function gpa(r As Range) As String
On Error GoTo Fail
For Each cell In r
Select Case UCase(Trim(r))
Case "A+": gpa = 4#
Case "A": gpa = 3.8
Case "A-": gpa = 3.6
Case "B+": gpa = 3.4
Case "B": gpa = 3.2
Case "B-": gpa = 3#
Case "C+": gpa = 2.8
Case "C": gpa = 2.6
Case "C-": gpa = 2.4
Case "D+": gpa = 2.2
Case "D": gpa = 1#
Case "D-": gpa = 1#
Case "F": gpa = 0
End Select
Next
Fail:
End Function
Function gpa(r As Range) As String
On Error GoTo Fail
For Each cell In r
Select Case UCase(Trim(r))
Case "A+": gpa = 4#
Case "A": gpa = 3.8
Case "A-": gpa = 3.6
Case "B+": gpa = 3.4
Case "B": gpa = 3.2
Case "B-": gpa = 3#
Case "C+": gpa = 2.8
Case "C": gpa = 2.6
Case "C-": gpa = 2.4
Case "D+": gpa = 2.2
Case "D": gpa = 1#
Case "D-": gpa = 1#
Case "F": gpa = 0
End Select
Next
Fail:
End Function
Function gpa(r As Range) As String
On Error GoTo Fail
For Each cell In r
Select Case UCase(Trim(r))
Case "A+": gpa = 4#
Case "A": gpa = 3.8
Case "A-": gpa = 3.6
Case "B+": gpa = 3.4
Case "B": gpa = 3.2
Case "B-": gpa = 3#
Case "C+": gpa = 2.8
Case "C": gpa = 2.6
Case "C-": gpa = 2.4
Case "D+": gpa = 2.2
Case "D": gpa = 1#
Case "D-": gpa = 1#
Case "F": gpa = 0
End Select
Next
Fail:
End Function
Function gpa(r As Range) As String
On Error GoTo Fail
For Each cell In r
Select Case UCase(Trim(r))
Case "A+": gpa = 4#
Case "A": gpa = 3.8
Case "A-": gpa = 3.6
Case "B+": gpa = 3.4
Case "B": gpa = 3.2
Case "B-": gpa = 3#
Case "C+": gpa = 2.8
Case "C": gpa = 2.6
Case "C-": gpa = 2.4
Case "D+": gpa = 2.2
Case "D": gpa = 1#
Case "D-": gpa = 1#
Case "F": gpa = 0
End Select
Next
Fail:
End Function