vba foreach loop code example
Example: for each loop vba
Private Sub Constant_demo_Click()
'fruits is an array
fruits = Array("apple", "orange", "cherries")
Dim fruitnames As Variant
'iterating using For each loop.
For Each Item In fruits
fruitnames = fruitnames & Item & Chr(10)
Next
MsgBox fruitnames
End Sub