+ Reply to Thread
Results 1 to 8 of 8

Macro to find column with duplicates, for each of those check another column for duplicate

  1. #1
    Registered User
    Join Date
    04-16-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2013
    Posts
    9

    Macro to find column with duplicates, for each of those check another column for duplicate

    Hello,

    I've been trying to hack together code that will let me do the following:

    1) In a certain column find duplicates.
    2) For those duplicates check another column for duplicates
    3) If found, highlight the rows.

    I have searched and found a thread which seemed an almost exact match but now I'm stuck: http://www.excelforum.com/excel-form...lete-rows.html

    The attached file should be helpful
    tester.xlsx

    The code I have found in the thread mentioned got me far, but now I'm stuck. Also I must admit that I do not know what I am doing. That is because the code does not have enough comments too explain what it does.

    Please Login or Register  to view this content.
    The result of the above code is highlighting a couple (wrong) cells. I know I should get rid of the Union declarations, but I don't know how to make sure the correct rows are highlighted. Also I do not understand how this code exactly finds duplicates in the first column, saves the rows which are dupes, and then checks for duplicates in those rows but in another column.

    As far as I understand it this will get all the entries in de B column, then put them in a dictionary array. But then it starts counting (I do not understand why) and after that I just do not have the skills to understand the code... yet .

    Any help would be greatly appreciated!
    Last edited by MaartenKoller; 05-17-2013 at 03:31 AM. Reason: Solved :)

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Try this:-
    Please Login or Register  to view this content.
    Regards Mick

  3. #3
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Try this macro
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-16-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Wow! That was fast! And both work exactly as they should while using a totally different method! Hats off to you Mick

    One more thing though because I forgot something. Can the code be tweaked to check if another cell has a value of 0 (zero) the code ignores that row?
    I have uploaded another file to explain by example so I can be more precise. It's on the third sheet. I have also added some real data (made anonymous) which has another exception.
    tester2.xls

    Thank you in advance!

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Try this:-
    This should only Highlight the first and last Duplicate of any group of duplicates and discount any row where Column C & D row have no data.
    Please Login or Register  to view this content.
    Regards Mick

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Try
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-16-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2013
    Posts
    9

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    Wow, that's awesome Mick! After a couple hours staring at your code and looking up most of it in reference sheets. Breaking your code several times during trial and error because of tweaking it now works!

    I ended up using the first macro and tweaked it. I also changes my requirements a little.

    This is the code that I am using now:

    Please Login or Register  to view this content.
    And it's awesome I'm going to change the title of this post to 'solved'. Thank you so much Mick! I am not only happy that it works, but also that I learned a lot in the process .

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Macro to find column with duplicates, for each of those check another column for dupli

    I'm pleased you've been able to modify the code to your needs and thank you for the feedback
    Regrds Mick

+ 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