'Excel Grading macros in VBA
Function gradeOf(cell) As String
'Looks at a cell, returns a letter grade using my standards
Dim grade As String
Select Case cell
Case Is < 0.65
grade = "F"
Case Is < 0.7
grade = "D"
Case Is < 0.74
grade = "C-"
Case Is < 0.78
grade = "C"
Case Is < 0.8
grade = "C+"
Case Is < 0.84
grade = "B-"
Case Is < 0.88
grade = "B"
Case Is < 0.9
grade = "B+"
Case Is < 0.94
grade = "A-"
Case Is < 0.98
grade = "A"
Case Else
grade = "A+"
End Select
gradeOf = grade
End Function
Function countAs(theRange) As Integer
'Given a range of cells, counts how many As Are in that range
Dim curVal
countAs = 0
For Each curVal In theRange
'MsgBox curVal
If InStr(curVal, "A") Then
countAs = countAs + 1
End If
Next
End Function
Function countBs(theRange) As Integer
'Given a range of cells, counts how many As Are in that range
Dim curVal
countBs = 0
For Each curVal In theRange
'MsgBox curVal
If InStr(curVal, "B") Then
countBs = countBs + 1
End If
Next
End Function
Function countCs(theRange) As Integer
'Given a range of cells, counts how many As Are in that range
Dim curVal
countCs = 0
For Each curVal In theRange
'MsgBox curVal
If InStr(curVal, "C") Then
countCs = countCs + 1
End If
Next
End Function
Function countDs(theRange) As Integer
'Given a range of cells, counts how many As Are in that range
Dim curVal
countDs = 0
For Each curVal In theRange
'MsgBox curVal
If InStr(curVal, "D") Then
countDs = countDs + 1
End If
Next
End Function
Function countFs(theRange) As Integer
'Given a range of cells, counts how many As Are in that range
Dim curVal
countFs = 0
For Each curVal In theRange
'MsgBox curVal
If InStr(curVal, "F") Then
countFs = countFs + 1
End If
Next
End Function