Anyone ever seen a case where FormatConditions.Count = -1 ?

  • Thread starter Thread starter roybrew
  • Start date Start date
R

roybrew

I have a case where I have a selected range (Application.Selection)
that I want to do some conditional formatting on and I am seeing a case
where Application.Selection.FormatConditions.Count is -1 instead of a
value between 0 and 3. Anyone ever seen this before? I am sure that
some sort of error condition exists, but don't know the significance of
Count = -1 except that I cannot add a condition. I believe the
selection is valid. Any help would be appreciated. TIA.

Roy
 
You'll see that if the selection contains cells with different
conditional formatting.
 
Debra,

Thanks for the reply. That explains it. We have an add-in that stores
some conditional formatting information in a database of sorts. When
we build the spreadsheet we accumulate this conditional formatting
information as a stream and therefore have to frequently go back and
add or modify conditions to already existing formatting information.
It apears that it is best if you do all of the conditional formatting
in one shot. That is, gather the info, and slam down the new
conditional formatting information on top of the old. If you do a
record macro, select a range and go thru the conditional formatting UI,
the first thing the macro does is:

Range("A4:C4").Select
Selection.FormatConditions.Delete

Thus clearing out the old before laying down the new. So it looks like
you cannot do additive conditional formatting on cells that already
have conditional formatting. You would have to completely replace it.

RoyB

(e-mail address removed)
 
Back
Top