vba for array loop code example
Example: vba for each array
' For each in an array: elements are considered as variant
Dim stringArray(1 To 2) As String
stringArray(1) = "a"
stringArray(2) = "b"
Dim element As Variant
For Each element In stringArray
Debug.Print element
Next element
' Or
Dim index As Long
For index = LBound(stringArray) To UBound(stringArray)
Debug.Print stringArray(index)
Next index