From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Repeat a task using a Do loop

Repeat a task using a Do loop - Microsoft Excel Tutorial

From the course: Excel: Learning VBA

Repeat a task using a Do loop

- [Instructor] When you create an Excel VBA subroutine, you expect it to perform a specific task. Sometimes though, you will want your VBA code to run until a condition is met. When you want a segment of your code to repeat until it encounters a specific condition, you can use the do loop construction. I'll demonstrate how to create the different kinds of do loops in this movie. My sample file is 03_03_DoLoops, and you can find it in the chapter three folder of the exercise files collection. In this workbook, I have two worksheets and on sheet one, which I've currently displayed, there is a form that is used as a suggestion box and you can see that it accepts the name, the email of the individual who is submitting the comment, and the text of their suggestion. That would be written to a collection table on sheet two. And you can see that I already have some data created on this worksheet. The goal would be to create a loop…

Contents