Loop through ranges : For Each « Language Basics « VBA / Excel / Access / Word






Loop through ranges

 

Sub TestAreas()
  Dim rng As Range
  For Each rng In Range("A1:B5,C6:D10,E11:F15").Areas
    MsgBox rng.Address
  Next rng
End Sub

 








Related examples in the same category

1.Using the For Each...Next Loop
2.Early Exit from a Loop
3.Using Nested Loops
4.For...Each Variation
5.Looping through the elements in an array