I don't understand why you can put "imynumber" in the first example and it will add 1 each time
The first one doesn't add anything. The first one is actually flawed code that will error. What you are thinking though is that it just keeps replacing the value so at the end of the loop "iMyNumber" is equal to the last number in the loop (in this case 100). Hence the point of the addition. To fix the first code it would require something like this:
Sub OurFor()
Dim iMyNumber As Integer
For iMyNumber = 1 To 100
iMyNumber = iMyNumber
Next iMyNumber
MsgBox (iMyNumber)
End Sub
Bookmarks