troubleshooting Question

Excel VBA used to delete conditional formatting crashes

Avatar of jobprojn
jobprojnFlag for United States of America asked on
Microsoft Excel
7 Comments1 Solution853 ViewsLast Modified:
Hello Experts.  I have the following piece of VBA code which goes through every third row within a range and deletes the conditional formatting.  It works fine (and is relatively fast) until there's more than a few hundred rows and it crashes.

Any ideas on how I can modify this so as to avoid a crash when running with 500+ rows in the spreadsheet?

Thanks.

Sub DeleteConditionalFormatting()

Dim lLastRow As Long, lRowLoop As Long

    Application.Calculation = xlCalculationManual 'turns off auto calculation until update is complete

        With Worksheets("Cycle Time")
        lLastRow = .Cells(.Rows.Count, "AD").End(xlUp).row
                    
                    For lRowLoop = 10 To lLastRow Step 3

                        With .Cells(lRowLoop, "AD").Resize(1, 5)
                            .FormatConditions.Delete
                        End With

                    Next lRowLoop
                
    Application.Calculation = xlCalculationAutomatic 'turns auto calculation back on
            
    End With

End Sub
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros