Thread: For Loop
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default For Loop

Sub test()
innerloopCellCounter = 1
For j = 1 To 82
Range("A" & j).Value = j
If j Mod 41 = 0 Then
For i = 1 To 41
Range("B" & innerloopCellCounter).Value = i
innerloopCellCounter = innerloopCellCounter + 1
Next i
End If
Next j
End Sub

"Harish" wrote:

i=1
j=1

For j = 1 to 81

if j <=20 Then
k = j+1
Else
k = j*mod(21)+2
End if
j=j+1
i=i+1
Cells(i, 3) = k
Next