Looping through the elements in an array : For Each « Language Basics « VBA / Excel / Access / Word






Looping through the elements in an array

 
Sub ArrayLoop() 
    Dim avColors As Variant 
    Dim vItem As Variant 

    avColors = Array("Red", "Green", "Blue") 

    For Each vItem In avColors 
        Debug.Print vItem 
    Next 
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.Loop through ranges
5.For...Each Variation