+ Reply to Thread
Results 1 to 10 of 10

not allowing duplicate entries from a list

  1. #1
    Registered User
    Join Date
    02-13-2011
    Location
    Highlands
    MS-Off Ver
    Excel 2003
    Posts
    25

    not allowing duplicate entries from a list

    Hi folks,
    I'm making up a spreadsheet for use at work using excel 2003 and I'm struggling a wee bit.

    I have a bank of serial numbers which i've set up in column P I've used the validation List function on column B where the serial numbers will be entered, so that the user can only enter a number from the column P list. What I'm looking to do is block the user from entering a serial number in Column B which has allready been entered so that column B contains only one instance of the serial number. Can anyone point me in the right direction please?
    Last edited by Kevska; 02-14-2011 at 08:14 PM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: not allowing duplicate entries from a list

    Hi Kevska and welcome to the forum,

    Will you accept some VBA code behind your workbook for an answer? I'm not seeing a good non-VBA method to do this. If your answer is "What's VBA", I'll have my answer.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    02-13-2011
    Location
    Highlands
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: not allowing duplicate entries from a list

    Quote Originally Posted by MarvinP View Post
    Hi Kevska and welcome to the forum,

    Will you accept some VBA code behind your workbook for an answer? I'm not seeing a good non-VBA method to do this. If your answer is "What's VBA", I'll have my answer.
    Well I know what VBA is but I've never done any. I'm willing to give it a try though if it'll do the job. :D

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: not allowing duplicate entries from a list

    You should send a sample workbook so the code works closer to what you have.

    Click on "Go Advanced" then on the PaperClip Icon above the message area. This will allow you to attach a sample file. I'll write a little code after the party.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: not allowing duplicate entries from a list

    One straightforward (but less than ideal) option is to add another column Q and use the data in Q for your data validation list instead of P. Each row in Q would refer to the list in P, but remain blank if the value is already found in B.

    So for example in Q2:

    =IF(COUNTIF(B:B,P2)>0,"",P2)

    The reason it is less than ideal is that your dropdown list will have blank lines in it, but it's a quick solution.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Registered User
    Join Date
    02-13-2011
    Location
    Highlands
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: not allowing duplicate entries from a list

    Ah Brilliant, thanks very much.
    Attached Files Attached Files

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: not allowing duplicate entries from a list

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  8. #8
    Registered User
    Join Date
    02-13-2011
    Location
    Highlands
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: not allowing duplicate entries from a list

    Quote Originally Posted by 6StringJazzer View Post
    One straightforward (but less than ideal) option is to add another column Q and use the data in Q for your data validation list instead of P. Each row in Q would refer to the list in P, but remain blank if the value is already found in B.

    So for example in Q2:

    =IF(COUNTIF(B:B,P2)>0,"",P2)

    The reason it is less than ideal is that your dropdown list will have blank lines in it, but it's a quick solution.
    This works a treat. Thanks very much! Before I close the thread though can you explain the formula to me? I like to understand how it works.

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: not allowing duplicate entries from a list

    Let me work from the inside out.
    COUNTIF(B:B,P2)
    The Excel function COUNTIF counts the number of times a value occurs in a specified range. In this case it counts the number of times the value in P2 occurs in column B (B:B means use the whole column).

    The IF part considers the result from that COUNTIF function.

    If the count is more than 0, then we leave the cell blank, because that value is already being used.

    Otherwise (i.e., the count is 0), we use the value as it appears in column P.

  10. #10
    Registered User
    Join Date
    02-13-2011
    Location
    Highlands
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: not allowing duplicate entries from a list

    I get it now, thanks very much, my spreadsheet is coming along nicely

+ 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