Delete all Conditional Formatting Q

  • Thread starter Thread starter Seanie
  • Start date Start date
S

Seanie

What code could I use to delete all Conditional Formatting in the
active workbook?

Thanks
 
Thanks Ron, 2007 is the version

How can I tweak to delete on all sheets in the active workbook?
 
Iterate through the sheets.

Option Explicit
Sub DeleteConditionalFormats()
Dim ws As Worksheet
Dim r As Range, c As Range
On Error GoTo NoCellsFound
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.SpecialCells(xlCellTypeAllFormatConditions).FormatConditions.Delete
Next ws
Exit Sub
NoCellsFound: MsgBox ("No Cells Found")
End Sub

Note: if any sheet has no CF you will get the error.


Gord Dibben MS Excel MVP
 
What am I doing wrong on below which debugs with message "no cells
found", I tried to tweak to delete all CF in all sheets, without any
message box display


Sub DeleteConditionalFormats()
Dim ws As Worksheet
Dim r As Range, c As Range
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.SpecialCells(xlCellTypeAllFormatConditions).FormatConditions.Delete
Next ws
Exit Sub
End Sub
 
Thanks Ron, I thought "On Error GoTo 0" handled that

One further twist, delete all CF except in Sheets1; Sheet2; Sheet3?
 
Back
Top