Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Ensuring Unique Values in a Column.

Ensuring Unique Values in a Column

Written by Allen Wyatt (last updated December 4, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


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. Click the Data tab of the ribbon.
  3. Click the Data Validation tool, in the Data Tools group. Excel displays the Data Validation dialog box. (See Figure 1.)
  4. Figure 1. The Data Validation dialog box.

  5. Using the Allow drop-down list, choose the Custom option.
  6. In the Formula box, enter the following formula:
  7.      =MATCH(D1,$D:$D,0)=ROW(D1)
    
  8. 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 5:

=COUNTIF($D:$D,D1)<2

There is one other thing to keep in mind: All bets are off if a user copies a value into a cell in the column. This results in the data validation information be overwritten as the copy is completed. If such a thing is likely to happen with your data, the only way around it is to create a macro that checks, after each action, whether the data validation has been removed from cells where it should be present. Such is not a trivial undertaking.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10673) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel 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. ...

MORE FROM ALLEN

Setting Up Multi-page Columns

Do you need a page layout that features columns that progress vertically across pages instead of horizontally across a ...

Discover More

Automatically Adding Tabs in Footnotes

When you add a footnote to a document, Word's normal formatting adds a space after the footnote number and before the ...

Discover More

Absolutely Positioning a Graphic

Want a graphic to appear at a precise place on the page? It's easy to gain control by following the steps in this tip.

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Adding Pop-Up Documentation to a Cell

Want to have a small help screen pop up when a user selects a particular cell? This can be done by using data validation, ...

Discover More

Limiting Choices in a Cell

Want to limit what a person can enter into a particular cell? You can use Excel's data validation feature to help enforce ...

Discover More

Prohibiting Single-Digit Entries in a Cell

The Data Validation capabilities of Excel can be very helpful when you are trying to control what people can enter into a ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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}] (all 7 characters, in the sequence shown) 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 2 + 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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

Newest Tips
Subscribe

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.