Hi all,
So I've wondered this for a while but cannot find any answers on Google due to the keywords being too general.
With a For...Next loop I've always specified my variable after the "Next" statement e.g.
or
I know that omitting the variable makes VBA automatically assign it (see here), but is there any advantage/disadvantage to specifying it explicitly?
Personally I find it adds an extra layer of reference but I was wondering if there are any programmatic advantages.
E.g. the following works the same as the first example:
Cheers
So I've wondered this for a while but cannot find any answers on Google due to the keywords being too general.
With a For...Next loop I've always specified my variable after the "Next" statement e.g.
Code:
For i = 1 to 5
Debug.Print i
Next i
Code:
For Each i In myArray
Debug.Print i
Next i
Personally I find it adds an extra layer of reference but I was wondering if there are any programmatic advantages.
E.g. the following works the same as the first example:
Code:
For i = 1 to 5
Debug.Print i
Next
Cheers