Microsoft Excel
--
Questions
--
Followers
Top Experts
continue a "do while" loop in VBA/Excel
do while .....
......
If InStr("abc", "b") > 0 Then continue Loop
......
loop
I get "Compile error: Â Expected: expression".
What's the problem?
If I remove "Loop" I receive another error...
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
generally, the code inside your loop will exit the loop when a condition is met, something like:
This would cause the code to jump to the next line outside of the loop. Â If "b" is found in "abc", then the code inside the loop would continue. Â The key is making sure that the code inside the loop provides one of two things:
1. Â a way to jump out of the loop and continue processing
2. Â a way to exit the subroutine (Exit Sub) or function (Exit Function)
do while .....
......
If InStr("abc", "b") = 0 Then Exit Do
......
loop
This would cause the code to jump to the next line outside of the loop. Â If "b" is found in "abc", then the code inside the loop would continue. Â The key is making sure that the code inside the loop provides one of two things:
1. Â a way to jump out of the loop and continue processing
2. Â a way to exit the subroutine (Exit Sub) or function (Exit Function)
no I just need to jump the case where the InStr returns > 0, continuing the loop to the next case  (not exiting the loop)
That's what my answer assumed. ;)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Thanks guys!
Microsoft Excel
--
Questions
--
Followers
Top Experts
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.