# Highlight Duplicate Values, Non Contiguous Cells

#### cloyd1980

##### New Member
Hi all,

I am trying to apply a simple conditional format where cells with the same value are highlighted. The problem I am running into is that the data I want to apply the formatting to is in every other row (2, 4, 6, etc). The formatting works fine if the the duplicate value appears in the same row (for example B2 and E2), but if the duplicate value is in a different row it does not work (for example B2 and B4). Does anyone know how to fix this?

Thanks,
Corey

#### DanteAmor

##### Well-known Member
Try :

- Select your range, ge. "B2:E20"
- Conditional Formatting, Highlight Cells Rules, and then Duplicate Values.

I hope that helps you

#### cloyd1980

##### New Member
The problem is that my data isn't in B2:E20, it would be in B2:E2, B4:E4, B6:E6, etc

#### DanteAmor

##### Well-known Member
Try :

- Select your range, eg. "B2:E20"
- Conditional Formatting
- In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
- Under Format values where this formula is true, type the formula:

Code:
``=AND(B2<>"",ISEVEN(ROW(B2)),SUM(IF(MOD(ROW([COLOR=#ff0000]\$B\$2:\$E\$20[/COLOR]),2)=0,IF([COLOR=#ff0000]\$B\$2:\$E\$20[/COLOR]=B2,1)))>1)``
- Applies to:
=\$B\$2:\$E\$20

Change \$B\$2:\$E\$20 for the desired range.

Last edited:

#### cloyd1980

##### New Member
Try :

- Select your range, eg. "B2:E20"
- Conditional Formatting
- In the New Formatting Rule dialog box, click Use a formula to determine which cells to format.
- Under Format values where this formula is true, type the formula:

Code:
``=AND(B2<>"",ISEVEN(ROW(B2)),SUM(IF(MOD(ROW([COLOR=#ff0000]\$B\$2:\$E\$20[/COLOR]),2)=0,IF([COLOR=#ff0000]\$B\$2:\$E\$20[/COLOR]=B2,1)))>1)``
- Applies to:
=\$B\$2:\$E\$20

Change \$B\$2:\$E\$20 for the desired range.

Dante, this worked perfectly! Thank you very much! I never would have come up with that formula on my own.

1,082,359
Messages
5,364,916
Members
400,815
Latest member
Joaquin Phoenix

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...