Thread: For loop
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default For loop

What is i ? Is that always 0...Also you have not mentioned the condition to
end the loop. Try the below and view the result in immediate window..


Sub Macro_Increment()

Dim i, j, k
i = 0: j = 0: k = 0

Do
If k = 4 Then j = j + 1: k = 0
Debug.Print i & "," & j & "," & k
k = k + 1
Loop Until j = 10

End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Harish" wrote:

hi,

I am looking for a formula that would give me a for loop. you can also
give me a code in VB too..

This is what I am looking for in the for loop.

i=0, j=0, k=0
i=0, j=0, k=1
i=0, j=0, k=2
i=0, j=0, k=3

i=0, j=1, k=0
i=0, j=1, k=1
i=0, j=1, k=2
i=0, j=1, k=3

and so on.....

any ideas?