+ Reply to Thread
Results 1 to 8 of 8

Preventing duplicates in a dynamic range

  1. #1
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Preventing duplicates in a dynamic range

    Hi all.

    I have a column of cells some 400 deep with food items in.
    This is a Vlookup and I want to prevent duplicate entries.

    There is something along these lines in data validation:

    =Countif(range,A1)<=1

    However column A will need to be a dynamic range as the user can add to it.

    So I need the data validation to check the dynamic range.

    I have set a dynamic range with offset and its called checkdups.

    I am sort of lost from here, In the first cell of the column I did data validation and typed:

    =Countif(checkdups,A1)<=1

    It did not return an error or anything, neither did it work.

    In essence if a user types text into a cell in this column that already exists I want excel to tell them to try again.

    Many thanks

    I am also considering how to deal with people changing the text of these items, how does VLOOKUP deal with that. In essence this worksheet contains allt he ingredients and other sheets vlookup this one to obtain the price, what if a user decides they don't need tomatoes any more (for instance) and deletes it, what effect does this have on other sheets that have referenced tomatoes?
    Last edited by NBVC; 01-18-2011 at 09:01 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Preventing duplicates in a dynamic range

    If I select the whole column, eg. Column A and apply Data Validation with Custom rule:

    =COUNTIF(A:A,A1)=1

    Then I can enter a certain string only once in column A.

    Is this what you mean?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Preventing duplicates in a dynamic range

    I need excel to keep an eye on column A so that if a user puts in say 'Onions' and onions is already they it will give the user an error 'pick something else' or what ever.

    Data validation would appear to cover this, but its applying it to a dynamic range that I am confused over. i.e. column A might have any number of cells in it.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Preventing duplicates in a dynamic range

    This is what the formula does..

    After selecting column A and apply the data validation rule, then try typing Onions. It should accept it... now try typing Onions again in another cell within column A. It should not accept it.

    Are we on the same page?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Preventing duplicates in a dynamic range

    Apply it to the whole column
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Preventing duplicates in a dynamic range

    Hi yes, to the whole column I need to do, there are currently 400 cells in the column, but the user might add another 20 or 50, if I apply to the whole column won't the formula get its knickers in a twist over empty cells, hense whay I am trying to apply to a dynamic range using offset.

    NBVC I tried your formula, it let me add a duplicate entry, without returning an error.
    Last edited by garyi; 01-17-2011 at 12:13 PM.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Preventing duplicates in a dynamic range

    try the attached....play with column A
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    08-31-2010
    Location
    andover
    MS-Off Ver
    Excel 2007
    Posts
    102

    Re: Preventing duplicates in a dynamic range

    Got it! I had a VBA button at the top which I assumed data validation ignored, but it didn't, once removed it worked fine

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1