'VBA For Each item in ... why does it not stop at the end
Hi struggling with some basic code ... could someone please explain this code, why does it shove 2 extra lines on the end ...
Sub main()
Dim item As Variant
Dim ifToSave As Variant
Dim fileType(5) As String
fileType(0) = "1"
fileType(1) = "2"
fileType(2) = "3"
fileType(3) = "4"
fileType(4) = "5"
For Each item In fileType
ifToSave = item & " - apple"
Debug.Print item
Debug.Print ifToSave
Next item
End Sub
Outputs this
1 1 - apple 2 2 - apple 3 3 - apple 4 4 - apple 5 5 - apple - apple
Where this doesnt
For i = 1 To 5
ifToSave = i & " - apple"
Debug.Print i
Debug.Print ifToSave
Next i
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
