Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional Formatting alternate rows and matching rows in Excel

I'm trying to apply conditional formatting to my data where I need to color the rows based on certain columns. If the current and previous rows have same data in 4 particular columns, I will color those rows. But I also need to apply this color to alternate rows.

So the result I need is like the format in the image below:

enter image description here

As in the sample image above, first two rows have same values in column Name1, Name2, Type_Name and Type_Code, they are colored. Then, the next row is skipped from coloring. And then the next row even if it does not have a matching row above or below, it will be colored. Then rows with Rita in Name1 are skipped.

So far I'm able to get to the rows with same values in the 4 columns and color the alternate rows, both the logics separately, but unable to apply the mix of both properly. Below are the logics applied so far.

  1. This one, where the rows have same values in the 4 required columns, using the formula

    =OR($H2&$I2&$J2&$K2 = $H1&$I1&$J1&$K1, $H2&$I2&$J2&$K2 = $H3&$I3&$J3&$K3)

enter image description here

  1. And alternate rows colored with the formula

    =MOD(ROW( ),2)=0

enter image description here

like image 468
Hariprasad Rao Avatar asked Jan 01 '26 21:01

Hariprasad Rao


1 Answers

I would first add a helper column which separates the groups.

This is done by checking if the relevant columns of the row is the same as the row above. If it is, we simply take the max value of the column, if it is different, we increment the max value by 1. We can then apply the conditional formatting if this helper column is an odd value:

enter image description here

like image 171
Gravitate Avatar answered Jan 03 '26 11:01

Gravitate



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!