What is the syntax for a For Loop?

For <variable> = <starting value> to <ending value>
     'code to be executed
Next

 

For example,

For i = 1 to 10
     Cells(i,i).Value = "Hello World"
Next

 

 

 

 

 

Advertisements