# preventing duplication

#### lezawang

##### Well-known Member
Hi
I know the formula to use to prevent duplication, thanks for your help. So I went to Data Validation->custome then wrote this formula

= countif(\$a1:\$a5,a1)=1

but did not fully understand it

here is my understanding

This formula will be apply on all the range

=countif(range,a1) =1
=countif(range,a2) =1
=countif(range,a3) =1
=countif(range,a4) =1
=countif(range,a5) =1

let say i want to enter 100 in cell a4, so the formula is =countif(range,a4)=1, so this formula is true because I have a1= 100 therefore excel wont accept me to enter that value. Am I right?

 100 200 300

<tbody>
</tbody>

#### Eric W

##### MrExcel MVP
You have the main idea. However, that formula only works on A1. CF adjusts the formula for each cell, just like copying and pasting a formula works on the sheet. So if you select A1:A5, and enter a DV rule equal to:

=countif(\$a1:\$a5,a1)=1

then in A1 it's:
=countif(\$a1:\$a5,a1)=1
then in A2 it's:
=countif(\$a2:\$a6,a2)=1
then in A3 it's:
=countif(\$a3:\$a7,a3)=1
etc.

So you need to enter a different formula in each cell, or better, change the formula to:

=countif(\$a\$1:\$a\$5,a1)=1

You could use a named range too.

Last edited:
• lezawang

1,082,043
Messages
5,362,825
Members
400,694
Latest member
Sofie17

### 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...