View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld[_2_] Ron Rosenfeld[_2_] is offline
external usenet poster
 
Posts: 1,045
Default Delete all Conditional Formatting Q

On Sat, 17 Jul 2010 09:34:48 -0700 (PDT), Seanie
wrote:

Thanks Ron, I thought "On Error GoTo 0" handled that


You need to read VBA HELP for the On Error statement
There is an error in my code in that it does not reset the error
function. It should read:

=================
Option Explicit
Sub DeleteConditionalFormats()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
On Error Resume Next
ws.Cells.SpecialCells(xlCellTypeAllFormatCondition s).FormatConditions.Delete
On Error GoTo 0
Next ws
End Sub
===================



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


Just test to see which worksheet you are cycling on; then skip the
loop if it is a sheet you're not interested in.

===========================================
Option Explicit
Sub DeleteConditionalFormats()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < "Sheet1" And _
ws.Name < "Sheet2" And _
ws.Name < "Sheet3" Then
On Error Resume Next
ws.Cells.SpecialCells(xlCellTypeAllFormatCondition s).FormatConditions.Delete
On Error GoTo 0
End If
Next ws
End Sub
======================================