Home » excel » Excel toggle row conditional highlighting based on row above

Excel toggle row conditional highlighting based on row above

Posted by: admin May 14, 2020 Leave a comment


I need to add some conditional highlighting to make something more readable. Screenshot below is the manually created version of what I want to make. Essentially toggle the highlighting per order but when an order has multiple lines make sure the highlight stays the same for the order.

UPDATE: As per the screen shot below (top table is the unformatted version and the one below is the formatted one) I basically want to highlight all the rows that have the same order id. So order id 1 would be unhighlighted, order id 2 would be highlighted, order id 3 would be highlighted etc… if those orders span multiple rows then they keep the same formatting until the next order id.

enter image description here

How to&Answers:

Highlight every even number based on your “Order ID” with conditional formatting:

So even number, where $B14 refers to your Order ID Column:


If you instead want to highlight odd number (this formula gives TRUE every time you have a odd number):


enter image description here



  1. Sort the data based on “Order ID”.
  2. Select the range – Home – Styles box – Conditional formatting – New Rule – Use Formula to dete.. – into Formula box paste “=COUNTIF($A:$A,$A2)>1” – Press format – Fill ans select color and press ok.


Specify what condition you need, right now you want just result but doesn’t says what should trigger formatting.

If you need to highlight whole row, select whole range (whole table).

And in conditional formatting put =$A1=”1″ this will highlight row if it matches “1”

And with addition of another column in table (maybe hidden) you should be able to find your solution