I rediscovered this very cool function while writing the CommentsControl add-in, and I thought that it’s, unfortunately, rarely used.
Here’s how MS defines it:
Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that is True.
Switch(expr-1, value-1[, expr-2, value-2 … [, expr-n,value-n]])
Basically, think of it as a special Select Case statement, like this:
The main advantage is that it is compact and easy to write, but the main disadvantage is that it evaluates *all* the expressions, like IIF(), so if one of them returns an error, Switch() will fail.
In my case, I used it to test 3 OptionButtons, like this
Choice = Switch(OptionButton1.Value, 0, OptionButton2.Value, 1, OptionButton3.Value, 2)