6. Using Flow-of-Control Statements

Branching and Looping

So far, nearly all the code that you’ve seen in this book has been strictly sequential. That is, execution starts at the top of each procedure, continues line-by-line through the procedure, and stops at the end of the procedure. The one exception to this rule that you’ve seen so far has been in error-handling code.

→ Error handling in VBA was covered in “Implementing Error Handling,” p. 52.

VBA is capable of more complex patterns of program execution than this, though. To write flexible VBA code, you need to understand the concepts of branching and looping. Branching ...

Get Business solutions Automating Microsoft now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.