Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditional Formats, how to scroll and view all formats? | Excel Worksheet Functions | |||
more than 3 conditional formats | Excel Worksheet Functions | |||
Conditional formats- paste special formats? | Excel Discussion (Misc queries) | |||
paste conditional formats as formats | Excel Discussion (Misc queries) | |||
Conditional Formats | Excel Discussion (Misc queries) |