Search code examples
excelvbacellhighlightconditional-formatting

How to highlight all cells of the same value in a column when a specific text is in another column


Hi I'm trying to use either VBA or conditional formatting for this but it doesn't work the way I want it to :/

Column B is a list of values that are keyed in by different people one at a time, column C is the status of the person. What I'm trying to achieve: ONLY when column C is "OUT", the value in the adjacent cell (in column B) is shaded and all the same values of that cell is shaded as well.

I can shade the column B cell given "OUT" in column C but I can't get all the same values before that to be shaded as well. There are 3 possible status: NEW, AFTERNOON, OUT

Anyone have any ideas please? I attached a photo I hope it explains abit clearer

enter image description here


Solution

  • Is there a way to highlight more than 2 cells? If I have 3 of same value, only the last 2 duplicates will be highlighted – geravie498 5 hours ago

    In such a case you only need one rule.

    Let's assume the data is in B1:C10. Adapt the formula accordingly.

    Match all the value of B1 in the range below where $B$1:$B$10=$B1 and $C$1:$C$10="OUT"

    RULE

    =INDEX($B$1:$B$10,MATCH(1,($B$1:$B$10=$B1)*($C$1:$C$10="OUT"),0))

    enter image description here