top of page

You are learning Data Validation in MS Excel

How to prevent duplicate entries using data validation?

Here's how to prevent duplicate entries using data validation in Excel:

1. Select the range: Choose the column or range of cells where you want to prevent duplicates.

2. Data Validation: Go to the "Data" tab on the ribbon. In the "Data Tools" group, click "Data Validation."

3. Settings: In the "Settings" tab of the Data Validation window, under "Allow," choose "Custom" from the dropdown menu.

4. Formula for uniqueness: In the "Formula" box, enter the following formula: `=COUNTIF($A$2:$A$20,A2)=1` (replace `A2` with your actual cell reference and adjust the range `$A$2:$A$20` to match your data area).

- Explanation:
- `COUNTIF` function counts the number of times a value appears in a specific range.
- `$A$2:$A$20` is the absolute reference to your data range (adjust as needed).
- `A2` is the relative reference to the current cell where the formula is being applied. This ensures the formula checks for duplicates compared to the entered value in the current cell.
- `=1` specifies that only one occurrence of the value is allowed.

5. Error Alert (Optional): In the "Error Alert" tab, you can customize the message displayed if a user tries to enter a duplicate value. For example, you could write: "This value already exists. Please enter a unique entry."

6. Click OK: Click "OK" to close the Data Validation window.

Now, when you try to enter a duplicate value in the selected range, Excel will display the error message you created (if any) and prevent the duplicate entry.

bottom of page