For…Next Loop Speedup

For…Next Loop Speedup

Whenever you use For.Next loops, it is faster NOT to use the countername after Next (of the For.Next loop). In nested loops, it produces significantlyfaster code.

 Sub Form_Load ()Dim TStart!Dim I As IntegerTStart! = Timer	For I = 1 To 32000	Next IDebug.Print Timer - TStart!TStart! = Timer	For I = 1 To 32000	Next ' I ' For readability, it is better 		' to show the counter name 		' by commenting it out. Debug.Print Timer - TStart!End Sub


Share the Post: