Google Sheets Prevent Duplicates in Column?

How-to basics · Updated November 23, 2026

Yes, Google Sheets can prevent duplicates in a column using Data validation with a custom formula, or by combining UNIQUE with data cleanup. The most direct method is to select the column, go to Data > Data validation, choose “Custom formula is,” and enter =COUNTIF(A:A,A1)=1 (adjusting the range to your column). This blocks entry of any value that already exists in that column.

Why Duplicates Happen and Why They Matter

Spreadsheets are often shared among multiple people, and even a single user can accidentally type the same email, product ID, or invoice number twice. Duplicates cause errors in VLOOKUP, pivot tables, and summary reports. For example, if you track order numbers and one is entered twice, a SUMIF over that column will double-count revenue. Preventing duplicates at the point of entry is more reliable than fixing them later, because it stops the bad data before it propagates.

How Data Validation Blocks Duplicates

Data validation is a built-in feature that checks what a user types against a rule. To set it up:

  1. Select the range where you want to prevent duplicates (e.g., A2:A1000). Do not include the header row if you have one.
  2. Click Data > Data validation.
  3. Under “Criteria,” choose Custom formula is.
  4. Enter =COUNTIF(A:A,A2)=1 (if your selection starts at A2). For a range starting at A1, use =COUNTIF(A:A,A1)=1.
  5. Choose what happens on invalid data: “Reject the input” or “Show warning.” Reject is stricter; warning allows entry but flags it.
  6. Click Save.

The formula counts how many times the value in the current cell appears in the entire column A. If that count is exactly 1, the entry is allowed. If it’s 0 (empty cell) it’s also allowed, which is fine. If it’s 2 or more, the entry is rejected or warned.

Using UNIQUE to Find and Remove Existing Duplicates

Data validation only prevents new duplicates; it does nothing about duplicates already in the sheet. To find them, use the UNIQUE function. For example, with data in A2:A100, place this in C2:

=UNIQUE(A2:A100)

This returns a list of unique values from that range. Compare the row count of the original range with the row count of the UNIQUE output to see how many duplicates exist. To remove duplicates permanently, you can copy the UNIQUE output and paste it as values over the original column, but that overwrites data, so make a backup first.

Conditional Formatting to Highlight Duplicates

If you prefer to see duplicates rather than block them, use conditional formatting. Select the column (e.g., A2:A1000), go to Format > Conditional formatting. Under “Format cells if,” choose Custom formula is and enter:

=COUNTIF(A:A,A2)>1

Set a formatting style (like a red fill) and click Done. This highlights every cell whose value appears more than once. It does not prevent entry, but it makes duplicates obvious. This is useful when you want to allow duplicates in some cases but still spot them.

Choosing Between Reject, Warning, and Highlight

The right choice depends on your workflow:

  • Reject the input – Use when a duplicate is always an error, such as unique IDs, email addresses, or ticket numbers. The user sees a red box and cannot enter the value.
  • Show warning – Use when duplicates might be intentional (e.g., a product code that can appear in multiple categories). The user sees a warning but can proceed.
  • Conditional formatting only – Use when you want to audit existing data or when you cannot block entries because the column legitimately contains repeats sometimes.

You can also combine methods: use data validation to reject and conditional formatting to highlight any pre-existing duplicates that were entered before the rule was added.

Common Problems and Limitations

Data validation with COUNTIF works per column, but there are a few gotchas:

  • Empty cells – The formula =COUNTIF(A:A,A1)=1 treats empty cells as valid because COUNTIF returns 0. That is usually fine.
  • Case sensitivity – COUNTIF is not case-sensitive. “Apple” and “apple” are considered duplicates. If you need case-sensitive, use =SUMPRODUCT(--EXACT(A:A,A1))=1, but this is slower on large ranges.
  • Copy-paste bypass – Data validation only triggers when a user types or pastes into a cell. If you copy a block of cells and paste over the range, validation may be ignored depending on paste options. Use “Paste special > Values only” to still trigger validation, or use a script for full enforcement.
  • Whole column references – Using A:A in COUNTIF is fine for most sheets, but on very large sheets (hundreds of thousands of rows) it can slow down. You can limit to a specific range like A2:A1000.
  • Existing duplicates – Data validation does not retroactively remove duplicates. You must clean them manually or with UNIQUE.

Comparing Google Sheets with Excel

Excel has a similar feature under Data > Data Validation with the same custom formula approach. The formula syntax is identical: =COUNTIF(A:A,A1)=1. However, Excel’s data validation also works when pasting, and it is generally faster on large datasets. Google Sheets’ advantage is real-time collaboration – the validation applies to all users simultaneously. Excel for the web also supports data validation, but the menu path is Data > Data validation (not “Data Validation” as in desktop). In Excel desktop, you can also use the “Remove Duplicates” button under Data > Remove Duplicates to clean existing data, which Google Sheets lacks (you must use UNIQUE or an add-on).

Frequently Asked Questions

Can I prevent duplicates across multiple columns?

Yes. To prevent duplicates based on a combination of two columns (e.g., first and last name), use a helper column that concatenates them, then apply data validation to that helper column. For example, in C2 enter =A2&"-"&B2, then set data validation on C2:C100 with =COUNTIF(C:C,C2)=1. You can hide the helper column if you want.

Does data validation work when someone pastes a list of values?

Usually yes, but not always. If you paste a single value, validation triggers. If you paste a block that includes invalid values, Google Sheets will reject the entire paste if “Reject the input” is set. However, if you use “Paste special > Values only,” validation still applies. Some browser extensions or scripts can bypass it, but standard paste works.

How do I remove duplicates that already exist?

Use the UNIQUE function to create a clean list, then copy and paste it over the original column as values. For example, with data in A2:A100, put =UNIQUE(A2:A100) in C2, select C2:C, copy, right-click A2, choose “Paste special > Values only.” This overwrites the original data, so save a copy first. Alternatively, use an add-on like “Remove Duplicates” from the Google Workspace Marketplace.

Can I allow duplicates only in certain rows?

Yes. Modify the formula to include a condition. For example, if you only want to prevent duplicates in rows where column B is “Active”, use =IF(B2="Active",COUNTIFS(A:A,A2,B:B,"Active")=1,TRUE). This allows duplicates in rows where B is not “Active”.

Why is my data validation not working on some cells?

Check that the range in the COUNTIF formula matches the column you selected. If you selected A2:A100 but wrote =COUNTIF(A:A,A1)=1, the formula references A1 instead of A2, which will incorrectly reject valid entries. Also ensure the “Apply to range” in the data validation dialog matches your selection. If you have merged cells, validation may not work as expected.

Is there a way to prevent duplicates without using a formula?

No, Google Sheets does not have a simple checkbox for “no duplicates.” The custom formula method is the standard way. You can also use Google Apps Script to write a custom onEdit trigger that checks for duplicates, but that is more complex and requires coding. For most users, the COUNTIF formula is sufficient.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.