Forum Discussion
LemonPeeler
Aug 25, 2022Copper Contributor
How do we exit a CASE SELECT block?
How do we exit an Excel SELECT CASE block? We have found a Microsoft Docs indicating that you can only use the EXIT SELECT command if it is between the SELECT (or SELECT CASE) and the matching END SE...
JoeUser2004
Aug 25, 2022Bronze Contributor
PS, I meant to add.... Are aware that there is an implied "exit select" at the end of each Case block?
In other words, for example:
Select Case expression
Case expression
statements
Case expression
statements
End Select
is equivalent to:
Select Case expression
Case expression
statements
GoTo afterEnd
Case expression
statements
GoTo afterEnd
End Select
afterEnd:
statements
So no "exit" or explicit GoTo statement is necessary, if that is all you want.
LemonPeeler
Aug 25, 2022Copper Contributor
Again, thank you for taking the time to respond. As you suggest here, this method worked fine after we resolved the issue of our GOTO statement compile error. The compile error resulted after inserting a code line break (underscore) after a THEN statement and before the subsequent commands. Thanks.