Forum Discussion
How do we exit a CASE SELECT block?
Once again, you are asking a syntax question without showing us the complete context in one form or another.
According to Excel VBA help, there is no Exit Select statement. Use a GoTo instead.
I think you are looking at documentation for .NET Visual Basic. That is a stand-alone compiler. Technically, it is a different language with different features and possibly different behaviors.
Admittedly, I have fallen into the same trap myself, because the two languages are "similar enough" perhaps 90% of the time.
- LemonPeelerAug 25, 2022Copper ContributorHello Joe, one other question if we may. Can we include a RESUME NEXT in a SELECT CASE routine to exit the select case, without processing subsequent commands, and then process the next item in a FOR loop?
- JoeUser2004Aug 25, 2022Bronze Contributor
LemonPeeler wrote: ``Can we include a RESUME NEXT in a SELECT CASE routine to exit the select case``
No. From the VBA help page for the Resume statement: ``Resumes execution after an error-handling routine is finished.`` To learn more about error-handling (albeit not relevant to your questions), see the VBA help page for the On Error statement.
For VBA help pages, I select offline help, not online help. Then I enter a keyword into the search window to the right of Help on the VBA toolbar.
-----
LemonPeeler wrote: ``[...] and then process the next item in a FOR loop?``
No. And there is no Continue statement in VBA.
Use GoTo for both purposes.
- LemonPeelerAug 25, 2022Copper ContributorThank you so much!
- LemonPeelerAug 25, 2022Copper ContributorThank you for the response. As a novice, we probably missed that the article didn't apply to Excel VBA. Furthermore, we solved this problem in the end when we solved the issue of using the GOTO statement, which was not functioning for us due to another error, which was also resolved. Thank you again!