+ Reply to Thread
Results 1 to 11 of 11

Macro to detect duplicates

  1. #1
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Macro to detect duplicates

    Hello,

    Looking for a code that would detect duplicate entries, and if found, stop the next macro ( via Call 'macroname') from running. If no duplicates are detected, it calls the second macro.

    Range from "Import"(A:A) to find in "Maps"(1:1), without deleting the entries in "Maps"

    The ones I find on the interwebs either delete the value,colour them, delete row or column. I just want it to stop any other macro from running ( I know how to add Msgbox)

    Pointing in the right direction greatly appreciated,

    Regards,

    Red

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro to detect duplicates

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Macro to detect duplicates

    Hello bakerman2,

    Thank you for the response.

    When I run the code it debugged on
    Please Login or Register  to view this content.
    when hovering over it it says "1 = 1002" and Ubound(b)=Type mismatch"?

    The data in Import(A:A) and Maps(1:1) are dates, does that make a difference?

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro to detect duplicates

    None.
    See example file. Change one of the dates on sheet Maps to match one on sheets Import.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Macro to detect duplicates

    Weird, but after I changed your sheet to the same formatting as I got, same error.

    Import.A1 = Date and Map.A1 = Import.A1-1 (need this to get some other code to work)

    Attached is your file with the above changes.

    I hope that (1:1) means Row, else I am looking like an idiot
    Attached Files Attached Files

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro to detect duplicates

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Macro to detect duplicates

    Merciekes, Thank you so much

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro to detect duplicates

    To stay in the general forum.
    What is Reset supposed to do?
    Post Example file in which you're working (dummy data if necessary) and all the code involved.

  9. #9
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Macro to detect duplicates

    Reset calls the clearing of the Range A2:E1002. After Import, your macro runs, to check if in the given range are any duplicates, to indicate that the user has selected the wrong file for import.

    And instead of the user clearing the range by him or herself manually, I tried to put it in front of the MsgBox when a duplicate was detected.
    Attached Files Attached Files

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Macro to detect duplicates

    How about this one?
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    07-14-2012
    Location
    Belgium/UK
    MS-Off Ver
    Excel 2003
    Posts
    111

    Re: Macro to detect duplicates

    Does the job, much appreciated

+ 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. Detect duplicates
    By HelpExc in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-04-2014, 04:40 PM
  2. Integrating COUNTIF and IF Functions to detect duplicates
    By JHric in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-04-2014, 04:03 PM
  3. Replies: 1
    Last Post: 07-30-2014, 02:37 PM
  4. [SOLVED] Macro to find duplicates, concatenate Unique Values, then delete old duplicates
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2013, 04:32 PM
  5. Replies: 2
    Last Post: 11-11-2011, 06:56 PM
  6. Replies: 17
    Last Post: 07-05-2011, 05:37 PM
  7. Detect duplicates in user form text boxes
    By ds84 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2009, 09:59 PM

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