Hello Everyone,
Some times we come across situations where we want to restrict duplicate values to be entered. For example in the attached file, we want to avoid entering duplicate invoice numbers.
Some times we come across situations where we want to restrict duplicate values to be entered. For example in the attached file, we want to avoid entering duplicate invoice numbers.
It can be possible with DATA VALIDATION Custom Formula:-
=COUNTIF($C:$C,$C1)=1
Here are the steps:-
1. Select the target column fully say Col C.
2. Click Data tab in the Ribbon, select Data validation.
3. In the Drop down, select Custom.
4. Enter the Formula and click Ok.
It will give an error message while entering first duplicate.
Explanation:-
The Target column which has been selected, is the Range on which Data validation applies. Excel interprates above formula in context of Each cell in the Target Range and decides whether that cell has Unique or Duplicate entry. The $C1 parameter of Countif formula is a Row relative range. So when excel moves to next cell downwards in the Target Range, $C1 changes to $C2 and so on, for each next cell. When user puts a duplicate in the cell and hit enter, excel immediately interprates above formula in regard of that cell (by changing $C1 accordingly) and throws a warning message as count of that cell value in the whole C column will become 2 which is not equal to 1. So condition =1 will get falsified and excel will throw error warning. This is how it works.
Note:- Copy and pasting the same Invoice No., will not generate any error. Hence, you need to enter the Invoice No by editing the cell.
Check the attached file:-
Comments
Post a Comment