Switch function
Summary
Returns first True expression's value.
Syntax
Switch(expr-1, value-1, [ expr-2, value-2…, [ expr-n, value-n ]])
The Switch function syntax has these parts:
Part
Description
exprRequired. Variant expression that you want to evaluate.
valueRequired. Value or expression to be returned if the corresponding expression is True.
Part
Description
exprRequired. Variant expression that you want to evaluate.
valueRequired. Value or expression to be returned if the corresponding expression is True.
Example
Example
This example uses the Switch function to return the name of a language that matches the name of a city.
Function MatchUp(CityName As String)
Matchup = Switch(CityName = "London", "English", CityName _
= "Rome", "Italian", CityName = "Paris", "French")
End Function
This example uses the Switch function to return the name of a language that matches the name of a city.
Function MatchUp(CityName As String)
Matchup = Switch(CityName = "London", "English", CityName _
= "Rome", "Italian", CityName = "Paris", "French")
End Function