The standard syntax for For-Next
loops is to repeat the loop counter variable after Next
(i.e. Next i
). Placing the loop counter variable after Next is not required and unnecessarily slows down your macro. Omit the loop counter variable after Next
to boost performance.
Standard For-Next Syntax
For i = iStart To iEnd
' Standard For-Next loop syntax has loop counter
' (i) after Next
Next i
Optimized For-Next Syntax
For i = iStart To iEnd
' Omit the loop counter variable after Next
' for better performance
Next
For i = iStart To iEnd
' Better yet…
' With nested and longer loops add the For statement
' as a comment after Next
Next ' For i = iStart To iEnd