SOLVED

Count number of cells in each row assigned different colors through Conditional formatting

Copper Contributor

Hello community!

 

I'm new here and have a question on how to count number of cells in each row that have been assigned different colors through Conditional formatting in Excel 365.

 

I have done extensive searches and replies to a post from 2017 by @Jamil Mohammad seems to be the closest to what I need but I couldn't quite get it to replicate to my situation. I replied to the post but it appears that it's been since deleted, perhaps due to age or completion, therefore I'm reposting the same inquiry afresh.

 

See attached sample file: sampleCFcolorCount.xlsm as a reference, or for assistance in accomplishing.

 

  • The background colors on cells $D$3:$F$5, a named range called COLORS2, have been applied using Conditional Formatting based on criteria met using values in columns B and C.
  • A value of 9 on 29-Apr is assigned a background color of "Green" (Hex #92D050) because it fell between the range of 8.5 and 10.5 per rules of item A.
  • The other values below and above that range were assigned "Red" (Hex #FF0000).
  • If either values equaled the range boundaries 8.5 or 10.5, they would be assigned "Orange" (Hex #FFC000), while blanks would not be assigned a background color and therefore should not be counted.
  • The CF formulas assigned are as follows, and apply to $D$3:$F$5
    • Blank ISBLANK(D8)
    • Green AND(D8>$B8,D8<$C8)
    • Orange OR(D8=$B8,D8=$C8)
    • Red AND(NOT(ISBLANK(D8)),OR(D8<$B8,D8>$C8))

I could not find a clean way to arrive at a COUNT for the expected values for each row (not aggregated) based on the conditions described (see attached sample).

 

Can this be accomplished without VB scripts? Whether via scripts or without, kindly provide me with a step-by-step explanation (I'm not an Excel expert) on how to accomplish this request. Please also feel free to modify the sample file in your response.

 

Many thanks!

-SMM

2 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@SteveMM 

Refer to the conditions instead of to the colors:

 

In H3:  =COUNTIFS($D3:$F3,">"&$B3,$D3:$F3,"<"&$C3)

In I3:   =COUNTIF($D3:$F3,$B3)+COUNTIF($D3:$F3,$C3)

In J3:  =COUNTIFS($D3:$F3,"<"&$B3,$D3:$F3,"<>")+COUNTIFS($D3:$F3,">"&$C3,$D3:$F3,"<>")

 

Fill down.

@Hans Vogelaar Great way to think about it - referencing the conditions instead of the actual colors - and it works beautifully! I would never have come up with those countifs formulas; thank you so much!

1 best response

Accepted Solutions
best response confirmed by allyreckerman (Microsoft)
Solution

@SteveMM 

Refer to the conditions instead of to the colors:

 

In H3:  =COUNTIFS($D3:$F3,">"&$B3,$D3:$F3,"<"&$C3)

In I3:   =COUNTIF($D3:$F3,$B3)+COUNTIF($D3:$F3,$C3)

In J3:  =COUNTIFS($D3:$F3,"<"&$B3,$D3:$F3,"<>")+COUNTIFS($D3:$F3,">"&$C3,$D3:$F3,"<>")

 

Fill down.

View solution in original post