简体   繁体   中英

Excel conditional formatting with multiple cell comparison

So what I need to do is highlight rows based on cell comparisons.

for example is A2 = D2 AND E2 Make it green.
but if A2 = D2 OR E2 but not both make it yellow
and if A2 <> D2 OR E2 make it red.

is that kind of comparison possible?

EDIT for Gordon K:

格式框

示例列A-E B为白色

Yes:

Make all the cells red, then...

在此处输入图片说明在此处输入图片说明

Check the order the formatting is applied is correct:

在此处输入图片说明

Gives you:

在此处输入图片说明

If you want the whole row to change colour, then just change the "Applies to" box to cover all the columns of interest.

Yes this is possible - this requires 3 separate conditional formatting rules:

(1) =and(A2=D2,A2=E2) [set rule to highlight GREEN] This works because the And function requires each argument (separated by commas) to be True, for the entire function to return true. If either argument is false, then the And function returns false.

(2) =and(or(A2=D2,A2=E2),D2<>E2) [set rule to highlight yellow]

This combines the And function above with an Or function. Or returns True if any one of its arguments is true. So first, this formula checks whether EITHER A2=D2 or A2=E2. But, if that happens, A2 might equal both results. So, we need to say that the Or statement needs to return True, but also, we need to make sure that D2 doesn't equal E2. If it does, then A2 = both of them. "<>" means "does not equal" in Excel (often represented in other languages by "!=").

(3) =and(A2<>D2,A2<>E2) [set rule to highlight red]

You should by now see how this one works.

Note that you should really take time to look through each of the boolean functions and understand how they work; without a fundemental understanding of boolean functions it will be hard to move forward with your class (which I assume this is for).

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