In this post, we will be taking a look at Loops.

A loop is a block of code that executes again and again until either an expression equates to false or is broken by way of an Exit statement. What makes loops useful is that they can work with arrays and collections, they can perform tasks over and over until a condition is met and they can perform calculations over and over until you force them to stop. There are several ways to express this need to loop and VBA isn’t short on constructs for doing it.

List of topics covered:

  • For…Next
  • For i = 1 to 10 : {code block} : Next
  • For…Step…Next
  • Use Step to Count Backwards
  • Using Dynamic startValue, endValue and stepValues
  • For…Each
  • Using Loops with Collections
  • Demonstrate with Arrays
  • Exit For
  • While…Wend
  • While (false)
  • Exit While
  • Loop/Do…Until/While
  • Nesting Loops
  • Nested Loops and Multidimensional Arrays
  • DoEvents

Downloadable Content

Code Examples VBA Fundamentals

PDF

Videos

For…Each

For…Next

Step

While Wend

Related Posts

01 – The VBA Editor
02 – Objects, Properties and Methods
03 – Data Types, Variables, Constants and Operators
04 – Events
05 – Functions, Sub-procedures And Arguments
06 – Debugging
07 – Conditionals And Branching
08 – Arrays And Collections
10 – Recordsets

Leave a Reply

Your email address will not be published. Required fields are marked *

Visit Us On TwitterVisit Us On FacebookVisit Us On Youtube