Conditional Formats

  • Thread starter Thread starter Alec
  • Start date Start date
A

Alec

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
 
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
 
Back
Top