+ Reply to Thread
Results 1 to 13 of 13

Compare two columns-delete duplicates from just ONE column

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    43

    Compare two columns-delete duplicates from just ONE column

    Hi,
    I have column A that is 1,500 records.
    I have column B with 40,000 records.

    Among the 40,000 records in column B, duplicates of ALL 1,500 records from column A exist.

    My question is: How do I find WHERE the 1,500 dupes are and how can I delete JUST those records? Please help...THANK YOU in advance!
    Last edited by dawsonsoo; 10-07-2009 at 05:36 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Compare two columns-delete duplicates from just ONE column

    In Column-C use something like this (adjusted for your actual ranges):

    =MATCH(B1,$A$1:$A$3,0)>0

    Note the use absolute references for the column-A.

    Which will return either TRUE or #N/A. Extend the formula down column-C for as many rows as usedin column-B.

    Next, use Advanced Filter with criteria and the option to copy the non-matching entries to another location.

    Make sure column-C has a header say, "Match" (w/o quotes)

    For the AF criteria cell use: ="<>TRUE"
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

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

    Re: Compare two columns-delete duplicates from just ONE column

    Assuming A1 and B1 are titles and not data, run this macro...it will use an empty column to delete the column B matches in one big delete command.

    Please Login or Register  to view this content.
    =======
    How to use the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.



    EDIT: Tip of the hat to Palmetto, this is the same idea just in a macro form.
    Last edited by JBeaucaire; 12-10-2012 at 03:04 PM.
    _________________
    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!)

  4. #4
    Registered User
    Join Date
    07-14-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Compare two columns-delete duplicates from just ONE column

    Palmetto,
    Worked Beautifully!!!!! I can't thank you enough...
    This bothered me ALL DAY and now I can go on.
    Thank you!

  5. #5
    Registered User
    Join Date
    08-09-2012
    Location
    Minneapolis
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Compare two columns-delete duplicates from just ONE column

    Macro works like a charm...thanks a lot.

  6. #6
    Registered User
    Join Date
    09-20-2012
    Location
    Yorktown, VA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Compare two columns-delete duplicates from just ONE column

    Thank you very much but I have a question:

    This indeed works great using Columns A and B but bombs out when I edit code to use Columns E and F. What am I missing? I'm just changing the A's to E's and the B's to F's.

    Thanks,

    Jim

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

    Re: Compare two columns-delete duplicates from just ONE column

    marshajr1,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Registered User
    Join Date
    12-10-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Compare two columns-delete duplicates from just ONE column

    My question is same as marshajr1 and I think its totally relevant to the topic. I had to sort columns A and G replaced B with G in above code but it didn't worked.

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

    Re: Compare two columns-delete duplicates from just ONE column

    Yes, I agree. Your question helps clarify the original posted solution and understanding that is important.

    So I will point out that in the post #3 I have highlighted a portion of the "formula" that is being inserted into the cells. That formula us using the R1C1 notation, so instead of writing $A1, we put RC1 which means (relative row - column 1).

    You need to be able to read R1C1 to understand. C2 means Column-2, or column B, C1 means column-1 or column A.

    So change those appropriately to use columns E and F, 5 and 6. Let us know how you get on.

  10. #10
    Registered User
    Join Date
    05-24-2013
    Location
    Florida
    MS-Off Ver
    Excel 2013
    Posts
    1

    Re: Compare two columns-delete duplicates from just ONE column

    Quote Originally Posted by Palmetto View Post
    Next, use Advanced Filter with criteria and the option to copy the non-matching entries to another location.

    Make sure column-C has a header say, "Match" (w/o quotes)

    For the AF criteria cell use: ="<>TRUE"
    Thank you Palmetto for the instructions! I am stuck on the last portion, and have a feeling this is due to me using Excel 2013 (office 365). When I get to the portion of using the Advanced Filter, I have 3 boxes: List Range, Criteria Range and Copy To.
    The List range I am leaving default, which is selected all columns and rows. I copied your text for the Criteria Range: ="<>TRUE" And for Copy To I selected the entire column E, which it put in that field for me Main!$F$1

    When I click OK, I get Reference is not valid. Are there any suggestions for this? I did get all my results of TRUE & #N/A, just trying to get the non-matching results copied over to a new column.

    Thank you!

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

    Re: Compare two columns-delete duplicates from just ONE column

    If you want to start an separate thread and attach a sample worksheet, I'll take a look.

  12. #12
    Registered User
    Join Date
    06-05-2013
    Location
    CA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Compare two columns-delete duplicates from just ONE column

    Quote Originally Posted by JBeaucaire View Post
    Assuming A1 and B1 are titles and not data, run this macro...it will use an empty column to delete the column B matches in one big delete command.

    Please Login or Register  to view this content.
    =======
    How to use the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.



    EDIT: Tip of the hat to Palmetto, this is the same idea just in a macro form.

    That code worked great for me. Thank you SOO much. I searched for 3.5 hours looking for this code. Nothing else worked.

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

    Re: Compare two columns-delete duplicates from just ONE column

    Glad it helped you. A good recommendation for upgrading to a more recent version of Excel falls here, there is a "Remove Duplicates" option built right in now.

+ 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