Switch
The VBA Switch function evaluates a list of Boolean expressions and returns a value associated with the first expression being True.
The syntax is: Switch( Expr1, Val1, [Expr2, Val2], [Expr3, Val3], ... )
The function arguments, Expr1, [Expr2], ... are one or more boolean expressions to be evaluated. The values, Val1, [Val2], ... are the values to be returned if the corresponding Expr1, [Expr2],... is the first True expression. If none of the supplied expressions evaluates to True, the Switch function returns the value Null.
Example
Dim score As Integer
score = 8
result = Switch(score >= 8, "good", score >= 6, "sufficient", score <= 5, "insufficient")
What is the difference between Switch and Select case?
Switch is a function ending up with a result, while Select case is a statement for conditional branching, it can be used broader. It can give a single result but also can start other actions.More info on Select Case.