I just typed an example and wrote "Next" in the fornext loop structure as "exit". Later I thought about it and it actually had a similar meaning, so I found the use of exit so that I won't confuse it again next time.
Exit the do... loop, for... Next, function, sub, or property code block.
Syntax
Exit do exit for exit function exit property exit sub
Exit do provides a method to exit the do... loop and can only be used in the do... loop. Of course, if you do not use exit do, an endless loop will occur. Exit do transfers the control to the statement after the loop statement, that is, the loop stops. When exit do is used in a nested Do... loop, exit do transfers control to the outer loop where exit do is located.
Exit for provides a way to exit the for loop and can only be used in the for... next or foreach... next loop. Exit for transfers control to the statement after next. When exit for is used in a nested for loop, exit for transfers control to the outer loop where exit for is located.
The exit function immediately exits from the function that contains the statement. The program continues executing the statement after calling the function.
Exit sub immediately exits from the sub process that contains the statement. The program continues executing the sub statement after it calls the sub statement.
In general, the application of exit is different from that of end. end only represents the end of a process, while exit not only represents the end of a possible process, but also the start of another process. It is equivalent to a baton. End indicates that the competition is over, while exit indicates that one link is over, and the other link begins.