I know this question came up several times already, but I believe that my problem is slightly different.
My goal is to color format every second line one an excel sheet for visual reasons. The code for that looks like this:
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
lC = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
For i = 2 To lastRow
On Error GoTo skipColor
Set rng = ws.Range(ws.Cells(i, 1).Address, ws.Cells(i, lC).Address)
rng.Interior.ThemeColor = xlThemeColorDark1
If i Mod 2 = 0 Then
rng.Interior.TintAndShade = -4.99893185216834E-02
Else
rng.Interior.TintAndShade = -0.249977111117893
End If
skipColor:
Debug.Print Err.Description
Next i
The iteration of the loop always stops at exact the same line. It seems as if Excel cache is full and no more cell formats can be saved. I tried the solution (second answer) from this post and used it for every iteration of the loop. No success.
One more thing: even though I added the On Error Goto skipColor
line, it still shows me the error message.
EDIT: The line that is highlighted when I hit debug on the error message is: rng.Interior.ThemeColor = xlThemeColorDark1
.