Select Case with Comparison operators : Comparison Operators « Language Basics « VBA / Excel / Access / Word






Select Case with Comparison operators

 
Public Function AssignGrade(studentScore As Single) As String
    Select Case studentScore
        Case 90 To 100
            AssignGrade = "A"
        Case Is >= 80
            AssignGrade = "B"
        Case 70 To 80
            AssignGrade = "C"
        Case Is >= 60
            AssignGrade = "D"
        Case Else
            AssignGrade = "F"
    End Select
End Function

Sub test()
   MsgBox AssignGrade(99)
End Sub

 








Related examples in the same category

1.Comparison operators in VBA
2.If/Then/Else with Comparison operators
3.<> operator