+ Reply to Thread
Results 1 to 11 of 11

How to check for duplicates in a column?

  1. #1
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Post How to check for duplicates in a column?

    I am trying to alert an user from typing an already existing entry in a column. My Column will have values like

    kat-1
    kat-2
    Amp-3
    Amp-1

    Below code here is checking for duplicates but it is doing by letter. For example, if the user were to enter 'k' it displays a duplicate entry message. But, I would like it to display the duplicate message for full text like "Kat-1"," Amp-1" etc.

    Please Login or Register  to view this content.
    Can anyone help with this problem?

    Thanks,
    excelkann

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to check for duplicates in a column?

    I used your code in a blank workbook typing in names (from your example) and duplicating them and the code did give the message, however, I did not get the message if I typed a letter like 'k' as in your example. I even tried it with 'A' and didn't get the message.
    I did notice that if there is a duplicate in column A and the duplicate is not removed, you will get the message until the duplicate is removed, no matter what is typed in a new cell. Is it possible there is still some duplicates somewhere in the column?

    Can you attach your workbook (desensitized) with your code?
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Post Re: How to check for duplicates in a column?

    Sheet 1 in the attached macro contains buttons at the top of columns A,B,C& E. All of these headers have the same userform associated with it. Click on any of these to open the
    userform and type 'K'for base product name and you should see a "duplicate entry" message. Essentially, I would like a duplicate entry message when full kat-1 is entered by user.


    Another strange thing is I am seeing a duplicate message, even when 'L' (which is not present in column A ) is entered. So, I am not sure if there is anything wrong with this code.

    Regards,
    excelkann
    Attached Files Attached Files

  4. #4
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to check for duplicates in a column?

    Ok, now that I see that you are using a UserForm, I see the problem you are having. I haven't come up with a solution yet, but I'm working on it when I can.
    Have you considered using conditional formatting for that column?

  5. #5
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to check for duplicates in a column?

    With the code below, I have the program to not display the duplicate entry message as soon as a single letter is entered.

    Please Login or Register  to view this content.
    The program is expected to display a duplicate entry message only when an exact match is entered. Currently, if the column contains 'kat-1' and the userinputs 'kat-2', the program is seeing 'kat-2' as a duplicate entry. While it should see only ' kat-1 ' as duplicate entry.

    @gmr4evr1- I need this problem to be fixed before tomorrow, I would appreciate it, if you can find a solution to it before then.


    Regards,
    excelkann

  6. #6
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to check for duplicates in a column?

    Someone else may have to jump on this one because I'm not sure I'll have it figured out before tomorrow with work and all.

  7. #7
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to check for duplicates in a column?

    Can anyone else take a look at this.

    Thanks,
    excelkann

  8. #8
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to check for duplicates in a column?

    Please Login or Register  to view this content.
    The Code above is checking for duplicates. The Only issue is that it is seeing the immediate entry from user as a duplicate. For example, when user types in 'kat-1', it gets an update into column A and later gets compared to itself in the for loop. Any idea on how to avoid this?

    Thanks,

  9. #9
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to check for duplicates in a column?

    I might have stumbled onto something here, give it a try
    Please Login or Register  to view this content.
    I combined your last code with your 1st one and I think we might be getting closer.

  10. #10
    Registered User
    Join Date
    04-04-2016
    Location
    USA
    MS-Off Ver
    2010
    Posts
    29

    Re: How to check for duplicates in a column?

    @gmr4evr1- Thanks for the code. I am using a similar code in my program like below.
    Please Login or Register  to view this content.
    End Sub

    Regards,
    excelkann

  11. #11
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: How to check for duplicates in a column?

    Nice job...it's a bit cleaner than the code I provided.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Check for duplicates on the same row, in column range F:O
    By johanna0507 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-18-2015, 11:54 AM
  2. [SOLVED] Code to check for duplicates in column
    By PDBartlett in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2014, 06:26 AM
  3. [SOLVED] Macro to find column with duplicates, for each of those check another column for duplicate
    By MaartenKoller in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-17-2013, 10:09 AM
  4. [SOLVED] Find Duplicates, check value in another column for each duplicate
    By labrooy in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 08-09-2012, 06:57 PM
  5. Script to check for duplicates in one column then alter adjacent column values
    By SebN in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-29-2010, 12:23 PM
  6. Macro to check for blank cell entry, copy previous value, and check for duplicates
    By xPunxNotDeadx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2009, 06:33 PM
  7. Fast way to check if column contains duplicates
    By richarddd in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-21-2008, 06:23 AM

Tags for this Thread

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