Search code examples
excelselectionconditional-formatting

Excel - Conditional Formatting Based on Selection


Suppose that I have following data

Initial Data

I want to perform conditional formatting in cells containing Y. For example if I select the cell Shirts I want all the cells where Shirts is Y to be highlighted yellow. Similarly if I select cell Books I want all the cells where Books is Y to be highlighted green.

How can I achieve that?

Expected Output (Shirts Output)

enter image description here


Solution

  • I set some conditional formatting so if I enter "T" in one cell (Y3) then the selected cells (Y$:Y200) get formatted yellow with a border like so:

    enter image description here

    Just expand the formula to do what you need, perhaps and() to include "book" etc

    And(y3="T",y4="Books")
    

    as an example. Edit and test as you need.