I want to highlight a cell[x,y] if

  1. cell[x,y+1] is equal to cell[x,y] and
  2. cell[x-1,y] is not equal to cell[x-1,y+1]

Is there any easy work sheet function to do this or do I have to write a python script?

1 Answer 1


One solution would be a conditional formatting.
The AND Function works with conditions and returns only TRUE or FALSE, which is what you use in conditional formatting.

Go to Conditional Formating => Create a new Rule => Use a formula to determine which cells to format.

More Generally on the AND and conditional formatting

If I put as a new rule for the whole worksheet:


I obtain the following color every time my two conditions are filled

enter image description here

In your example, you can put the code:


And put it in the cell Formatting Rule for the cell C3. Then by applying this rule to your whole worksheet you should get


With this your whole worksheet should format the cell according to your two rules

  • It should be =AND(A1<>A2,B1=B2) Commented Jul 12, 2018 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .