Random colour changing with cell Interior.Color

Viewed 6434

I cobbled something simple together to see what would happen, and of course I broke excel.

Sub colourChange()

    Dim r As Byte, g As Byte, b As Byte

    On Error Resume Next

    For l = 0 To 50
        For j = 1 To 22
            For k = 1 To 66
                r = WorksheetFunction.RandBetween(0, 255)
                g = WorksheetFunction.RandBetween(0, 255)
                b = WorksheetFunction.RandBetween(0, 255)
                Cells(j, k).Interior.Color = RGB(r, g, b)
            Next k
        Next j
        Application.Wait Now + #12:00:03 AM#
    Next l

End Sub

It starts well, and then beings to slow down to a virtual standstill, eventually even producing the Too many different cell formats error.

Is there any way I can speed it up and stop the errors? I looked it up, excel is supposed to support 4000 different cell formats, and I shouldn't be hitting even half of that! Is it remembering the previous ones or something? What's going on here?

2 Answers
Related