rubikscube991
Member
hey Hii. I was trying to learn nested loop, but i encountered a problem. I have put 3 level loops. As per my understanding loop shall run 5X5X5=125 times. But it is running only 45 times.
I am not able to figure out where i am wrong. Below is the code. I tried many things but its not working. pls help. thanks a lot. Sheet attached for reference.
thanks........
I am not able to figure out where i am wrong. Below is the code. I tried many things but its not working. pls help. thanks a lot. Sheet attached for reference.
Code:
Sub ColourCheck2()
Dim a, b, c As Integer
Application.ScreenUpdating = False
For a = 0 To 4
For b = 0 To 4
For c = 0 To 4
Sheet2.Cells(c + b + 1, a + 1).Value = a * 20 & " " & b * 20 & " " & c * 20
Sheet2.Cells(c + b + 1, a + 1).Interior.Color = RGB(a * 20, b * 20, c * 20)
Next
Next
Next
Application.ScreenUpdating = True
End Sub
thanks........
Attachments
Last edited by a moderator: