Range specified for 'Case' statement is not valid

An invalid range has been specified for a Case statement.

When you are comparing the same expression to several different values, you can use the Select...Case statements as an alternative to the If...Then...Else statements. While the If and ElseIf statements can evaluate a different expression in each statement, the Select statement evaluates a single expression only once and then uses it for every comparison. Each Case statement can contain more than one value, a range of values, or a combination of values and comparison operators.

Error ID: BC40052

To correct this error

  • Modify the range to include all values, or use a Case Else statement to catch an undefined value.

See Also

Concepts

Decision Structures

Widening and Narrowing Conversions

Reference

Select...Case Statement (Visual Basic)