PC Review


Reply
Thread Tools Rate Thread

Delete Method as it applies to format Condition object

 
 
DTP
Guest
Posts: n/a
 
      7th Aug 2009
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

 
Reply With Quote
 
 
 
 
Sam Wilson
Guest
Posts: n/a
 
      7th Aug 2009

Worksheets("X").Range("A1").FormatConditions(1).Delete

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).Delete


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
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      7th Aug 2009
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
>

 
Reply With Quote
 
DTP
Guest
Posts: n/a
 
      7th Aug 2009
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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum of data where a condition applies =?Utf-8?B?a2lwcGVycw==?= Microsoft Excel Misc 1 20th Mar 2007 12:45 PM
How to create a Delete method which frees memory occupied by my object lexcel Microsoft Excel Programming 2 3rd Jul 2006 12:08 AM
Word applies direct format on File open Uriel Microsoft Word Document Management 16 27th Nov 2005 07:22 PM
Finding out which GP object applies a drive mapping script Rick Microsoft Windows 2000 Group Policy 3 16th Mar 2004 07:53 PM
Delete Method of Range object doesn't work in VB script vera Microsoft Excel Programming 1 17th Jan 2004 01:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 PM.