+ Reply to Thread
Results 1 to 11 of 11

Macro for duplicate records

  1. #1
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Macro for duplicate records

    Hi Everyone,

    I have a spreadsheet with over 60K entries and it grows on a monthly basis. I'm looking for a macro that will search a single column and return all entries that are duplicates. I have attached a workbook as an example to the data I will be viewing.

    The macro will need to look under Column F and create a list (can be in the same sheet or separate sheet) of all the entries that have duplicate serial numbers.

    Thanks in advance for your help.
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for duplicate records

    You don't really need a macro, you can add a column to the data to do the "test" then apply a standard AutoFilter to see the resulting "duplicate rows" right on the original sheet.
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Macro for duplicate records

    The problem lies with the number of records, with over 60,000 records sifting through a list that identify the duplicates can become difficult. It is why I was hoping to have a macro run through the table, identify a duplicate, paste it in a new sheet or the side and then list the number of times it was repeated. Hope that clarifies what I'm trying to accomplish.

    Thanks though for the effort.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro for duplicate records

    Hey Savio,

    You can try this code.
    Please Login or Register  to view this content.
    It will transfer all the duplicates to Sheet 2 and then give you a count of the duplicates per serial number in Sheet 3.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Macro for duplicate records

    hi, savio21, please check attachment, run code "test"
    Attached Files Attached Files

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Macro for duplicate records

    Did the code work for you?

  7. #7
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Macro for duplicate records

    Unfortunately, it didnt work artu. I get a "Run time error '1004'. Select method of Range Class failed" and debugging highlights this part of the code:

    Please Login or Register  to view this content.
    Watersev, your code doesn't accomplish exactly what I'm looking for. I'm expecting the serial number to show up and then a column beside it to identify the number of times it is repeated. For example, the test file should report 2111 in a different cell or sheet and say its repeated 4 times (including the first occurrence).

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for duplicate records

    Try this, then, it uses the formula suggestion I gave in post #2, but puts it in via macro, then filters the results for you onto another sheet, no looping.

    Please Login or Register  to view this content.

    Note, this will even work if you move your Serial # column.

  9. #9
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Macro for duplicate records

    Awesome, this is perfect! Thanks JBeaucaire!

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for duplicate records

    One little edit to make it truly adjustable regarding the Serial # column being anywhere:
    Please Login or Register  to view this content.

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  11. #11
    Registered User
    Join Date
    04-02-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    62

    Re: Macro for duplicate records

    Unfortunately, I tried the code on my full data set and it took way too long to run (over 65,000 rows of data). Thanks for help though, it will certainly be useful when I'm using smaller data sets.

    There doesn't seem to be an Edit box for my original post; I can see them for responses but not the original post.

+ 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