Loop termination - VBA For Excel

As long as the comparison test is true,the block of code in the body of the loop continues executing. When the test becomes false, the loop terminates and VBA begins program execution at the statement following the Loop statement which signals the end of the loop. As soon as the Do While s comparison test becomes false, the loop terminates and doesn t execute even one more time. The test appears at the top of the loop, so if it is false the first time the loop begins, the body of the loop will never execute.

contains the same program as in the previous listing using a Do While Loop to asks the user for an age. If the user enters an age less than 25 or more than 65, the program returns an error message as before. It continues looping, asking for the age, as long as the user enters an age that’s out of range.

Using Do While loop to control a loop

Using Do While loop to control a loop


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

VBA For Excel Topics