Nexted For Statements don't execute fully

  • Thread starter Thread starter EJKorvette
  • Start date Start date
E

EJKorvette

I am trying to use the following code to display all cell colors with all
border colors.
For some reason that I can't understand though, execution always stops
before the nested for statements can finish. The most it will get through is
i = 55 and j = 42.

Sub color()
Dim i, j As Integer
i = 0
j = 0

Worksheets("sheet4").Visible = True
For i = 1 To 56
For j = 1 To 56
Range("a3") = i
Range("a6") = j

Worksheets("Sheet4").Cells(i, j).Interior.ColorIndex = i
Worksheets("Sheet4").Cells(i, j).Borders.ColorIndex = j

Next j
Next i

End Sub

Is there some kind of internal limit Excel has to how many color
combinations can exist on one worksheet? I know that there are a maximum of
4000 styles, but there are only 55 * 42 = 2310 combinations here, not styles.
Why won't the program execute all the way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top