简体   繁体   中英

Conditionally format one cell based on values in a column

The user enters a date/time into cell B2. If this matches one of the values in column LI would like to format cell B2 as red, else format cell B2 as green.

在此输入图像描述

Any idea how to do this?

Please format B2 green with standard fill, then apply the following Use a formula to determine which cells to format , Format values where this formula is true:

=match(B2,L:L,0)>0  

with formatting (red) to suit and Applies to B2.

Assuming you are using Excel 2007 onwards:

  1. Set cell shading for B2 = Green
  2. Select Cell B2 and select the Conditional Formatting > New Rule menu item
  3. Use a formula to determine which cells to format
  4. In the formula bar, put in =ISNUMBER(MATCH(B2,$L$6:$L$100,0))
  5. For format, change shading to Red

Obviously change the $L$6:$L$100 to suit you, but that should do it...

What about breaking this up into two steps.

Try putting a simple formula in Cell B1 :

=ISNUMBER(MATCH(B2, L:L, 0))

This will return a TRUE if there's a match and a FALSE if there is not a match. Then make two conditional rules based on Cell B1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM