+ Reply to Thread
Results 1 to 27 of 27

Copy/Paste duplicates from multiple columns

  1. #1
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Copy/Paste duplicates from multiple columns

    Hi guys,

    So I have 2 massive excel files (around 40,000 rows each). I have column A-O in both files that need to be compared for duplicates, and then paste these duplicates somewhere else so I can double check. So, is there a macro that compares these columns and pastes the duplicates that it finds?
    I'd appreciate anyone's help an input. I work on a mac and have excel 2011.

    Thanks guys!

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Copy/Paste duplicates from multiple columns

    I wonder if something like the following would do it for you
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This checks cells in Column A against cells in Column C and outputs a match if there is one or nothing if there isn't.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Could you explain the formula? Thanks!

  4. #4
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    I've been trying to work on it and I think this is a better way of tackling it. I would want to copy and paste the duplicates in a sheet called "Duplicates' (workbook 1) if all the data in column C, D, E, G, H and I in a sheet called "A-L" (workbook 1) is exactly the same as the data in columns C,D,E,G,H,I in a sheet called "A-L" (seperate, workbook 2).

    Any suggestions greatly appreciated.

    Cheers,
    R

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Copy/Paste duplicates from multiple columns

    It seems that you may in fact need some code written for this. It would make things a lot easier to create a procedure for if you uploaded non-sensitive and personal data within the workbooks. Providing a before and after scenario would greatly help your cause too.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Hi Sush23,

    Try this with your Duplicates sheet active:

    Please Login or Register  to view this content.
    Last edited by xladept; 08-21-2012 at 03:28 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  7. #7
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Hi xladept,

    Firstly THANKS!
    Here is a bit more information because Im not sure what to put where when trying to replicate this.

    So, I have workbook 1: 2 Sheets: "A-L" and "M-Z"
    workbook 2: 2 Sheets: "A-L" and "M-Z"

    An entry is considered a duplicate if the data in columns C - E and G-O are exactly the same

    I need to check for duplicates within each sheet AND check if there are duplicates in "A-L" from sheet 1 when compared to "A-L" from sheet 2, and same thing for "M-Z"

    "A-L" on workbook 1 has 27,949 rows
    "A-L" on workbook 2 has 55,288 rows

    "M-Z" on workbook 1 has 22,829
    "M-Z" on workbook 2 has 46,859

    I guess I can just eliminate the duplicate if the entry is exactly the same instead of copying and pasting the duplicates and checking them myself. I'm anticipating a substantial amount of duplicates so going though them myself anyway would defeat the purpose. That's why the data in all those columns needs to match up.

    Let me know if you need more information and unfortunately I cannot upload the files they contain super sensitive information. Thanks guys I appreciate your help. As you can see these files are massive.

    Cheers,
    R

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Hi Sush23,

    I haven't tested these - I'd use the Copy before I used the Dump:

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by xladept; 08-21-2012 at 04:44 PM.

  9. #9
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    When I try to run the copy, it tells me its an invalid next control variable reference. Any ideas? It also highlights the the name subAOCullcopy() in yellow.

    Thanks so much for your help again

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Hi Sush23,

    At the end of LoadR2: it should read:

    Please Login or Register  to view this content.
    In both routines - sorry!

    Here's the Dump again:

    Please Login or Register  to view this content.
    Are they sorted? Are the individual workbooks clean? I've been working on a block deletion version and if they're clean and sorted we can speed it up significantly - but first it needs to be working!
    Last edited by xladept; 08-21-2012 at 06:30 PM.

  11. #11
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    they are sorted by Last name. Also for this I should have a workbook named "duplicates" right?

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Well - is the last name in column C? Yes, you need a Duplicates Book with "A-L" and "M-Z" sheets on it for the copy. You would need no sheet for the dump.

  13. #13
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    It still gives me the same error message as before. And yes sorted by last names in Column C. I am also writing this code in the Duplicates workbook. I dont know if that makes a difference

    ---------- Post added at 06:06 PM ---------- Previous post was at 06:00 PM ----------

    Also it now says "sub or function not defined" and highlights Dupes in Dumpduped1. I'm thinking it should be Dupes1 or dupes2

    Thanks again so much

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Yes, it should be Dupes1 or Dupes2. Did you fix the Next i to Next j? Here's the copy again (and the jazzed-up dump):

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    For both now it says "subscript out of range" Im so sorry for asking so many questions!

    Cheers

  16. #16
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    I don't mind the questions as I can't test it here. Are your Workbooks named something other than "Workbook 1" and "Workbook 2"?

    Are the sheets on them named "A-L" and "M-Z" ? They have to be exact. They have to be open too!

  17. #17
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Yeah they are names Workbook 1 and Workbook 2. and all the sheets are A-L and M-Z.

  18. #18
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Did it highlight anything? What about the other book - "Duplicates"?

  19. #19
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Everything seems to be exactly the same. "Duplicates" "Workbook 1" and "Workbook 2" I have another sheet on both workbooks, but that is not pertinent to the duplicate search. No no highlights everywhere. I will give it a look again, but both codes give me the same error.

    Thanks again so much

  20. #20
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Oops, I didn't let the k range all the way to "O" - change all the 14's to 15's. Can you send me a sample??

  21. #21
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Hi Sush23,

    I made myself a sample file and for my sample - these versions are now operating:

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by xladept; 08-22-2012 at 03:27 PM.

  22. #22
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Still no luck, gives me the same error. Where should I look for something that might cause this?

    Thanks for taking the time.

    Cheers,
    R

  23. #23
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    The indices can generate that error and message - Oh, I missed a couple of 15's that you'd best fix- but on my test data the trial was error free and gave the correct results?????

    Are you single stepping it thru (F8)?

  24. #24
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Yeah that's strange. I triple checked the names and they match, could it be an array error? No Im just running the macro as is. Missed a couple of 15's? where exactly?

    Cheers,
    R

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    Where does it choke when you step through?


    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    08-09-2011
    Location
    Colorado Spgs, USA
    MS-Off Ver
    Excel 2008
    Posts
    34

    Re: Copy/Paste duplicates from multiple columns

    Changed all the 14's to 15's, for some reason it not even letting me single step with with F8. I don't know if the fact that I have a mac makes a difference.

    Again, many thanks

  27. #27
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Copy/Paste duplicates from multiple columns

    I don't know about Macs - I don't think it should matter. Can you fabricate a sample with faux data?

+ 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