SOLVED

Conditional formatting based on 2 columns of text.

Copper Contributor

I want to alternate the fill color as below without having to do it manually. I will often have thousands of lines and this can be tedious. Every time either the "Stop Name" or "Line" changes, I want it to change to either no fill or blue. The number of lines varies between 1 and 4. Any suggestions?

Robert1967_0-1597174178742.png


Robert Gauthier

4 Replies
best response confirmed by Robert1967 (Copper Contributor)
Solution

@Robert1967 

Select the range you want to format conditionally.

In the following, I'll assume that:

  • The range begins in row 3.
  • The active cell in the selection is in row 3.
  • The Stop Name and Line columns are column A and B, respectively.

On the Home tab of the ribbon. select Conditional Formatting > New Rule...

Select 'Use a formula to determine which cells to format'.

Enter the formula

 

=MOD(SUM(--(IF($A$3:$A3<>$A$2:$A2,1,0)+IF($B$3:$B3<>$B$2:$B2,1,0)>0)),2)=0

 

Click Format...

Activate the Fill tab.

Select the light blue fill color.

Click OK, then click OK again.

 

Warning: it might be slow.

@Hans Vogelaar 

Hi I tried out the solution you came up with but was unable to make it work... are you sure about it?

@Hans Vogelaar 

WOW! Thank you very much. Works perfectly.

Awesome !!

 

1 best response

Accepted Solutions
best response confirmed by Robert1967 (Copper Contributor)
Solution

@Robert1967 

Select the range you want to format conditionally.

In the following, I'll assume that:

  • The range begins in row 3.
  • The active cell in the selection is in row 3.
  • The Stop Name and Line columns are column A and B, respectively.

On the Home tab of the ribbon. select Conditional Formatting > New Rule...

Select 'Use a formula to determine which cells to format'.

Enter the formula

 

=MOD(SUM(--(IF($A$3:$A3<>$A$2:$A2,1,0)+IF($B$3:$B3<>$B$2:$B2,1,0)>0)),2)=0

 

Click Format...

Activate the Fill tab.

Select the light blue fill color.

Click OK, then click OK again.

 

Warning: it might be slow.

View solution in original post