Quantcast
Channel: Active questions tagged worksheet-function - Super User
Viewing all articles
Browse latest Browse all 928

Conditionally format cells based on match in another sheet

$
0
0

I have an Excel spreadsheet with 2 worksheets. The first is just a header row and a single column of item names. The second is a list of item groups, with a header row and a title in the left most column, with each subsequent row being one item or another from the other sheet:

Sheet1:            Sheet2:+-------+--+--++-------+-------+-------+-------+-------+| Item  |  |  |    | Group | Item1 | Item2 | Item3 | ...+-------+--+--++-------+-------+-------+-------+-------+| Shirt |  |  |    | A     | Shirt | Hat   | Tie   |+-------+--+--++-------+-------+-------+-------+-------+| Hat   |  |  |    | B     | Socks | Shirt | SHOES |+-------+--+--++-------+-------+-------+-------+-------+| Socks |  |  |    | C     | Hat   | Socks |       |+-------+--+--++-------+-------+-------+-------+-------+| Tie   |  |  |    | D     | Tie   | Tie   | Socks |+-------+--+--++-------+-------+-------+-------+-------+| ...   |  |  |+-------+--+--+

I'd like to conditionally format all the cells in "Sheet2" such that any value that does not match a value in the first column of "Sheet1" is marked with a red background; those that do are marked with a green background. So all the cells in this example starting at B2 would be green except the value "SHOES". The value beneath that has nothing entered so would not be formatted at all.

The formatting rule for green I've tried is:

=AND(NOT(ISBLANK(B2)), COUNTIF(Sheet1!$A2:$A1000,B2)>0)

For red, about the same:

=AND(NOT(ISBLANK(B2)), COUNTIF(Sheet1!$A2:$A1000,B2)<1)

Both rules are "applied to" somewhat arbitrary range (I'd like it to apply to the whole sheet, less the topmost and leftmost row/col):

=$C$3:$E$10,$C$36:$Q$50,$E$11,$C$11,$C$2,$E$2:$Q$2,$C$12:$E$35,$F$3:$Q$35

This semi-works, but the results are unpredictable. Some values highlight as I expect but only for a few rows, and others don't. Probably my ranges are out of whack somehow, but I don't use Excel nearly as much as I once did. Can anyone lend a hand?

Thanks!


Viewing all articles
Browse latest Browse all 928

Trending Articles