+ Reply to Thread
Results 1 to 9 of 9

Compare two rows of numbers. Remove the duplicates

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    33

    Compare two rows of numbers. Remove the duplicates

    Hi again

    Is it possible to compare two rows of numbers:

    Example:
    Please Login or Register  to view this content.
    And compare it with
    Please Login or Register  to view this content.
    And then remove the numbers that are identical, leaving only behind numbers that dont occur in BOTH.

    I tried using the function "Remove Duplicates" didnt work that well, as it just compared each line to the other column like this; "Compare A12 to B12". I want it to compare the whole column and search for the exact same number in both columns.

    Thanks, I feel like this is a tricky one :P

  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: Compare two rows of numbers. Remove the duplicates

    This macro will do it... assuming:

    List1 is column A
    List2 is column B
    Columns D and H are empty and can be used

    Please Login or Register  to view this content.

    How/Where to install 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 as a macro-enabled workbook

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    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
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Compare two rows of numbers. Remove the duplicates

    Hello and welcome to the forum,

    There are several ways to accomplish this, but there are several factors to determine the best opiton for you.

    1) How long are your real lists?
    2) Is there any associated data on the same column that will also be deleted or is the whole data one column?
    3) Is this a one-time issue or will you be repeating this on a regular occasion?
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Registered User
    Join Date
    06-19-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Compare two rows of numbers. Remove the duplicates

    My real list is about 200 cells.

    I am comparing a invoice (all items charged the customer) with what has been manually put into our bills-system. I want to find out what misses in the invoice that is present in the bill-system, and also what is in invoice and has not been entered into the bill-system. Could call it a two way comparison.

    The numbers are sort of "order ID's" meaning column A is all orders from invoice, column B is all from bill-system.

    I will most likely be using this on a regular basis.

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Compare two rows of numbers. Remove the duplicates

    JB's solution should work well in this situation.

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Compare two rows of numbers. Remove the duplicates

    Hi

    Another option not using VBA,is this.

    Name your Lists as List1 & List2

    Then in C2(C1, is the title or empty), use this Array formula(Control+Shift+Enter) not just Enter and copy down,

    =IFERROR(IFERROR(INDEX(List1, MATCH(0, COUNTIF($C$1:C1, List1), 0)), INDEX(List2, MATCH(0, COUNTIF($C$1:C1, List2), 0))), "")

    Is this, works for you?
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  7. #7
    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 rows of numbers. Remove the duplicates

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Compare two rows of numbers. Remove the duplicates

    or use advanced filter!
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    06-19-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Compare two rows of numbers. Remove the duplicates

    JB's solution worked perfectly, thanks for all the help guys

+ 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