For, For Each, Do While loops

VBA loops repeat instructions. For goes through a counter, For Each goes through the elements of a collection such as the cells of a range or the sheets, Do While repeats as long as a condition is true. A badly written exit condition creates an infinite loop.

Example

For i = 2 To 100 Cells(i, 3).Value = Cells(i, 1).Value * 2 Next i

Related concepts

The whole glossary