ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete Method as it applies to format Condition object (https://www.excelbanter.com/excel-programming/432146-delete-method-applies-format-condition-object.html)

DTP

Delete Method as it applies to format Condition object
 
I am trying delete conditional formats for a specific range of cells. The
Help documentation all say to use the Delete Method to delete a
formatcondition but I do not see a specific delete method for Format
conditions. Here are some instances I have tried but all generate errors.
With Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, 5))
.DeleteFormatConditions (1)
.DeleteFormatConditions (2)
.DeleteFormatConditions (3)
End With
or
Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, )).FormatConditions
(1).Delete

Does anyone know the syntax for using the Delete Method to delete
conditional formats (Format Conditions)?

Thanks


Sam Wilson

Delete Method as it applies to format Condition object
 

Worksheets("X").Range("A1").FormatConditions(1).De lete

is right - if you get run time error 1004 it's because there are no
conditional format conditions to delete! To avoid that you can use

On error resume next
Worksheets("X").Range("A1").FormatConditions(1).De lete


Sam

"DTP" wrote:

I am trying delete conditional formats for a specific range of cells. The
Help documentation all say to use the Delete Method to delete a
formatcondition but I do not see a specific delete method for Format
conditions. Here are some instances I have tried but all generate errors.
With Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, 5))
.DeleteFormatConditions (1)
.DeleteFormatConditions (2)
.DeleteFormatConditions (3)
End With
or
Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, )).FormatConditions
(1).Delete

Does anyone know the syntax for using the Delete Method to delete
conditional formats (Format Conditions)?

Thanks


Jacob Skaria

Delete Method as it applies to format Condition object
 
Msgbox Range("d:d").FormatConditions.Count

Range("d:d").FormatConditions(1).Delete

If this post helps click Yes
---------------
Jacob Skaria


"DTP" wrote:

I am trying delete conditional formats for a specific range of cells. The
Help documentation all say to use the Delete Method to delete a
formatcondition but I do not see a specific delete method for Format
conditions. Here are some instances I have tried but all generate errors.
With Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, 5))
.DeleteFormatConditions (1)
.DeleteFormatConditions (2)
.DeleteFormatConditions (3)
End With
or
Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, )).FormatConditions
(1).Delete

Does anyone know the syntax for using the Delete Method to delete
conditional formats (Format Conditions)?

Thanks


DTP

Delete Method as it applies to format Condition object
 
Ok, So thanks for clearing up the question on the correct use of the Delete
Method on FormatConditions. This now works. However I needed to change the
way I addressed the range and the sequence of deletes. Here is the final
working module. There were 2 additional issues.
1. In my range was a mix of cells with and without Cond Formats. that was
genrating the 1004 code. The "On error resume next" got me past that.
2. Then becasue I was deleteing Format Condition (1) first by the time I got
to FormatCondition (3) there was no 3, it became FormatCondition (1) when the
other 2 were deleted. so it looked like it wasn't working.
Any way it works now and Thanks All for your help! Here is the final solution.

On Error Resume Next
For Each c In Worksheets(TargetWS).Range(Cells(5, 6), Cells(TargetRw, 6))
c.FormatConditions(2).Delete
c.FormatConditions(1).Delete
Next c

"Jacob Skaria" wrote:

Msgbox Range("d:d").FormatConditions.Count

Range("d:d").FormatConditions(1).Delete

If this post helps click Yes
---------------
Jacob Skaria


"DTP" wrote:

I am trying delete conditional formats for a specific range of cells. The
Help documentation all say to use the Delete Method to delete a
formatcondition but I do not see a specific delete method for Format
conditions. Here are some instances I have tried but all generate errors.
With Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, 5))
.DeleteFormatConditions (1)
.DeleteFormatConditions (2)
.DeleteFormatConditions (3)
End With
or
Worksheets(TargetWS).Range(Cells(5, 5), Cells(TargetRw, )).FormatConditions
(1).Delete

Does anyone know the syntax for using the Delete Method to delete
conditional formats (Format Conditions)?

Thanks



All times are GMT +1. The time now is 05:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com