+ Reply to Thread
Results 1 to 4 of 4

Userform VBA to check 2 columns (A & B) for duplicate entries

  1. #1
    Registered User
    Join Date
    04-15-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    2

    Userform VBA to check 2 columns (A & B) for duplicate entries

    Hi Folks

    This is my first post so please excuse the simplicity of the request

    I have a userform that I use for data entry with lots of combo boxes, list boxes and text boxes

    One thing i haven't cracked yet is to check for duplicates against two matching fields

    Let me explain

    If a user (for example) enters 'SAB' (which will be stored in column A) and then 'UK' (which will be stored in column B) and there is already an exact match for both, then I need to inform the user that a matching record already exists

    The following is OK: (the dots below are meant to illustrate spaces between the columns!!)
    Col(A).....Col(B)
    SAB........UK
    SAB........USA
    SAB........Italy

    BUT, if a user then tries to enter:

    Col(A).....Col(B)
    SAB........UK

    I need my userform to register a duplicate entry.

    My sub routine is detailed below

    Many thanks for any help,

    Steve

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Userform VBA to check 2 columns (A & B) for duplicate entries

    Hi,

    I wasn't 100% sure from your code which variables where which but you could do something like:
    Please Login or Register  to view this content.
    to check if search_a and search_b exist on the same row, you need to assign the user entry fields to search_a and search_b and then the evaluate function will return true if it is a duplicate.

  3. #3
    Registered User
    Join Date
    04-15-2014
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Userform VBA to check 2 columns (A & B) for duplicate entries

    Thanks for your reply ragulduy - appreciate it

    However, I need to substitute the text entries for actual variables. I have modified your code to do the following

    Please Login or Register  to view this content.
    The problem now is that I end up with a 'Run-time error '13' - Type mismatch

    I can see that my variables are being correctly substituted with the text field entries but I get the error

    Any ideas?

    Thanks, Steve

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Userform VBA to check 2 columns (A & B) for duplicate entries

    Sorry, you need to add quotation marks to either sides of what you are searching, so:
    Please Login or Register  to view this content.

+ 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. Userform - check for duplicate entries
    By glynnhicks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2013, 10:48 AM
  2. check for duplicate entries - from bottom to top?
    By Armitage2k in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2011, 05:27 AM
  3. Is there an easy way to check for duplicate entries?
    By Barons in forum Excel General
    Replies: 6
    Last Post: 07-06-2011, 02:45 PM
  4. Anyway to check for duplicate entries?
    By DarkSoul in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-19-2009, 04:03 PM

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