Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Ensuring Unique Values in a Column.

Ensuring Unique Values in a Column

by Allen Wyatt
(last updated June 16, 2017)


When you are entering information in a worksheet, you may want to ensure that the data being entered is actually unique for a particular column. For instance, if you are entering a series of invoice numbers in column D of a worksheet, you may want to ensure that you don't enter the same invoice number twice.

There are a couple of ways that you can approach such a problem. If you are always entering your new information at the bottom of a column, you can use Excel's data validation feature to make sure that whatever you are entering in the current cell does not match anything higher up in the column. Simply follow these steps:

  1. Select column D.
  2. Choose Validation from the Data menu. Excel displays the Data Validation dialog box. (See Figure 1.)
  3. Figure 1. The Data Validation dialog box.

  4. Using the Allow drop-down list, choose the Custom option.
  5. In the Formula box, enter the following formula:
  6.      =MATCH(D1,$D:$D,0)=ROW(D1)
  7. Click on OK.

If you may be entering data anyplace within column D, and you want to know if you are entering a value that is elsewhere in the column (above or below the current cell), then you can follow the above steps, but use this formula in step 4:


ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2650) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Ensuring Unique Values in a Column.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Inserting Endnotes

Endnotes appear at either the end of a section or the end of an entire document. It is just as easy to insert an endnote ...

Discover More

Putting Cell Contents in Footers

Referencing information between cells in a worksheet is a piece of cake using some elemental formulas. You cannot, ...

Discover More

Word 2010 Indexes and Special Tables (Table of Contents)

One of the finishing touches used in some types of documents are an index or a special table, such as a table of ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Limiting Input to a Format

When setting up a worksheet for others to use, you might want to make some limitations on what can be entered in certain ...

Discover More

Stopping Validated Data from being Overwritten

Data Validation is a great tool to make sure that data entered in a cell meets whatever criteria you decide. Its ...

Discover More

External Data Validation

When using data validation, you may want to reference a list of validation criteria contained on a different worksheet. ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 2?

2017-03-09 12:05:30



2016-05-06 11:41:51


This formula worked great when I tested it in a blank excel worksheet. But, when I tried it within my existing table it did not work :( Got any idea of how to get it to work in a table? Seems like there's a lot of things that don't work well within a table in excel. Thanks, Jenni

2016-01-23 13:07:31

Kadr Leyn

Thanks for tutorial.

Vba codes can be used in this topic:

"Excel Data Validation List With Unique Values"

Template's video :

2016-01-13 12:33:01


I must be missing something?
running MS Office 2016
not getting any messages

2015-11-23 08:08:53



2015-08-12 19:19:22


I want to avoid duplicate data in a comibnation of columns like

Valid Data
Date | Shift
08 Aug | Night
08 Aug | Day

Example of INVALID data
Date | Shift
08 Aug | Night
08 Aug | Night

So I have to avoid entry of duplicate data in a combination of columns. I am not able to figure it out please help.

2015-06-16 02:53:38


thank you for this tip

2014-08-18 02:30:57


Thanks for the tip!

2013-11-14 07:47:21

Michael (Micky) Avidan


In order to avoid duplicate typing and/or copying - try th following Event-macro to be placed in the Worksheets module.
The "traditional" Data Validation is not needed in that case.

*** The macro refers to Column "A".

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim C As Range, i As Long
If Not Intersect(Target, Me.[A:A]) Is Nothing Then
Application.EnableEvents = False
For Each C In Target
If C.Column = 1 And C.Value > "" Then
If WorksheetFunction.CountIf(Me.[A:A], C.Value) > 1 Then
i = C.Interior.ColorIndex
f = C.Font.ColorIndex
C.Interior.ColorIndex = 3 ' Red
C.Font.ColorIndex = 6 ' Yellow
MsgBox "Watch Out !!! - Duplicate Entry !", vbCritical, "Error"
C.Interior.ColorIndex = i
C.Font.ColorIndex = f
End If
End If
Application.EnableEvents = True
End If
End Sub

Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2014)

2013-11-13 22:37:09


Hi Allen,

I thought to let you know that the current formula I am using is:


Kind Regards,

2013-11-13 22:35:21


Hi Allen,

Thanks for your tips regarding unique values in a column - worked a treat.
I wanted to extend this info and allow unique values for the column cell range based on a list.
I have already created a form combo box with a list of four values that are in the column N1, N2, N3 and N4.
I would like the unique values only based on the selection in the drop down list.
Can you help me?

Kind Regards,

2013-06-10 14:50:48

Yesenia Bernal

Hello Allen,

I tried you how to enter values in a column and it worked great. I just have a question it there's a way for it to when you paste numbers not just entered numbers.

Thank you,
Yesenia Bernal

2012-06-02 15:40:39

Elaine Wilson

Thank you such a useful formula

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.