Specifying Multiple Expressions in a Case Clause

You may specify multiple conditions within a single Case clause by separating each condition with a comma:

Select Case myMonth

Case "January", "February", "March" Debug.Print myMonth & ": 1st Qtr."

Case "April", "May", "June"

Debug.Print myMonth & ": 2nd Qtr." Case "July", "August", "September"

Debug.Print myMonth & ": 3rd Qtr." Case "October", "November", "December" Debug.Print myMonth & ": 4th Qtr." End Select

Tip 5-7: Multiple Conditions with Case Clause

The commas used to separate conditions within a Case clause have the same meaning as the OR operator used in the If statement. The Case clause is true if at least one of the conditions is true.

0 0

Post a comment