ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional Formats (https://www.excelbanter.com/excel-programming/279845-conditional-formats.html)

Alec

Conditional Formats
 
How can I test if a selection contains conditional
formats, the following does not work.

" IF Selection.FormatConditions(2) = True Then ""

I am trying to delete FormatCondition (2) within a
selection, but if any cell within that selection does not
have any conditional formats, I get an error. I want to
the code to continue, regardless of the error.

Any Ideas
Alec



Corran Horn

Conditional Formats
 
On Fri, 17 Oct 2003 02:15:57 -0700, Alec wrote:

How can I test if a selection contains conditional
formats, the following does not work.

" IF Selection.FormatConditions(2) = True Then ""

I am trying to delete FormatCondition (2) within a
selection, but if any cell within that selection does not
have any conditional formats, I get an error. I want to
the code to continue, regardless of the error.

Any Ideas
Alec


That doesn't really involve conditional formatting, but rather
Error-handling.

To disregard error-messages, use to following line in your code:

On Error Resume Next

This makes sure that errors no longer cause a message. You can use the
Err-variable to see what kind of errors you encounter and you can use this
in your code with if-statements or something. Or just disrespect the
error-codes.

Once you do want to receive errors, place the following in your code:

On Error Goto 0

This resets the error-handling to default.

And I think you could also use the following:

"If Selection.FormatConditions.Count 1 then ***CODE***"

This way you trip the if-statement when there are more than 1 conditional
formatting in place...

HTH
CoRrRan

Alec

Conditional Formats
 
Thanks Corran

It works a treat, you've also helped me out on another
little problem I had.




-----Original Message-----
On Fri, 17 Oct 2003 02:15:57 -0700, Alec wrote:

How can I test if a selection contains conditional
formats, the following does not work.

" IF Selection.FormatConditions(2) = True Then ""

I am trying to delete FormatCondition (2) within a
selection, but if any cell within that selection does

not
have any conditional formats, I get an error. I want to
the code to continue, regardless of the error.

Any Ideas
Alec


That doesn't really involve conditional formatting, but

rather
Error-handling.

To disregard error-messages, use to following line in

your code:

On Error Resume Next

This makes sure that errors no longer cause a message.

You can use the
Err-variable to see what kind of errors you encounter and

you can use this
in your code with if-statements or something. Or just

disrespect the
error-codes.

Once you do want to receive errors, place the following

in your code:

On Error Goto 0

This resets the error-handling to default.

And I think you could also use the following:

"If Selection.FormatConditions.Count 1 then ***CODE***"

This way you trip the if-statement when there are more

than 1 conditional
formatting in place...

HTH
CoRrRan
.



All times are GMT +1. The time now is 01:27 PM.

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