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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.