The use of 'do while' in Excel macros helps us to automate the manipulations that we wish to do with the data in excel worksheet cells. The main points to remember when using a 'do while' loop is:
- Initialize the starting point of the loop
- Define the conditions under which the loop will run and stop
- Perform the loop
- Inside the loop you can define other conditions, let's say, do something 'if'
- Go to the next row or data
- Terminate the loop
If we forget to define any of these steps either the loop will not execute correctly or get into an infinite loop. This is what happens when we say the computer has 'hung'. Pre the ss 'escape =esc' key on the top left of the keyboard to stop the loop and then correct any errors.
The video below demonstrates the concept.
|