Forum Discussion
Macros suddenly run much slower
It's only taken 2 years but I finally found the issue for us. We have a very large workbook for production planning that we've been using for 15 years, and around early 2022 it slowed way down, and got worse and worse. It turns out in one of the worksheets, the conditional formatting rules had been duplicated 17,000+ times.
What's strange is that no macros run to change anything on that worksheet, although they do reference data from it. I looked at a Dec 2021 copy of the workbook and the worksheet only had the original dozen or so conditional formatting rules. I found a reference on another forum that the duplication of conditional formatting rules is a recent bug in Excel - it happens when deleting/copying worksheets within a workbook (even though for us the worksheet with the problem is never deleted or copied, although others are every week).
I was unable to delete the conditional formats from the worksheet using the GUI...Excel would just crash. I was able to do it with the following code. I adjusted the loop parameters to delete 5000 conditional formats each time I ran it, took about 30 minutes to do each 5000. But workbook macros are back to normal speed and don't seem to be duplicating now.
Sub Remove_New_Formatting()
Dim i As Long
Sheets("<worksheet name>").Activate
With ActiveSheet.Cells.FormatConditions
For i = .Count To 3 Step -1
.Item(i).Delete
Next i
End With
End Sub