How To Exit A VBA Loop

Hi, there are times when you need to exit a loop after a certain condition has been met.

How do you exit function in VBA?

In the following example, you are going to see how to exit a function in VBA:

How do you stop loop in VBA?

In the following example you’ll discover how easy it is to exit the vba loop.

For the “For” loop just tell the code, to “Exit For”.

and for the “Do” Loop just tell the code to “Exit Do”.

In some instances “Exit For” or “Exit Do” doesn’t work. In these cases try using the keyword “End” (check out this sample) or add a “Go To (something)” label, then exit the sub there.

Want to see a “Do WHILE LOOP” in Access VBA? Ciick me.

You are also going to find out:
What does a loop do in VBA?

Hopefully that helps someone. Let me know if you have any questions.

Click here for related posts on looping and exiting in VBA.


Free! Subscribe To Our YouTube Channel!

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather
Tags: , ,




 

Call Erik Now