+ Reply to Thread
Results 1 to 15 of 15

Compare 2 columns, delete cells with no match

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Compare 2 columns, delete cells with no match

    I need to compare 2 columns on the same sheet, A & B, and then delete the cells in column A that do not match column B...Column A has 9153 rows and B has 1923 rows.

    I had this matching the rows and returning the values that matched to another sheet in the workbook, but deleting the cells that don't match on the same sheet would be 10x more beneficial for me.

    If someone could please help me out it would be much appreciated!
    Last edited by cmd; 07-27-2010 at 12:28 PM.

  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 2 columns, delete cells with no match

    A1 match to B1, A2 match to B2, etc?

    Or A1 match column B anywhere, A2 match to column B anywhere?
    _________________
    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
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Compare 2 columns, delete cells with no match

    Sorry I didn't clarify...anywhere in the columns that they match

    ex. B1 = A232, B2 = A649 and so on

  4. #4
    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 2 columns, delete cells with no match

    So in effect, you will be searching the SMALL set of numbers for the ones that match in the BIG set, yes? Then you want an indication of which match?

    A formula which would tell you...put this in C1 and copy down:

    =ISNUMBER(MATCH(B1, A:A, 0))

  5. #5
    Registered User
    Join Date
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Compare 2 columns, delete cells with no match

    Both of the columns are words and I would like to delete the ones in that subset that are not the same as in the large one

  6. #6
    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 2 columns, delete cells with no match

    Try this macro version of the same idea on a COPY of your data, it will leave only the matches:
    Please Login or Register  to view this content.

  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 2 columns, delete cells with no match

    This version will delete values ONLY in the subset:
    Please Login or Register  to view this content.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Compare 2 columns, delete cells with no match

    Or possibly in C2

    =INDIRECT("B"&MATCH(A2,B:B,0))

    Filter on not #N/A and copy the result

    Hope this helps

    [EDIT]
    Where did the last 3 posts appear from???...
    Last edited by Marcol; 07-27-2010 at 11:05 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  9. #9
    Registered User
    Join Date
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Compare 2 columns, delete cells with no match

    This just deletes everything in the column and doesn't leave the matches...and I know that there are matches there
    Please Login or Register  to view this content.
    Last edited by cmd; 07-27-2010 at 11:21 AM.

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Question Re: Compare 2 columns, delete cells with no match

    I think the first formula of:
    =ISNUMBER(MATCH(B1, A:A, 0)) - in C1
    should have been
    =ISNUMBER(MATCH(A1,B:B,0)) and then copy down.

    You can then sort all three columns by column C and delete the cells in A that match FALSE.

    See attached sheet?
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Compare 2 columns, delete cells with no match

    Does it matter how long the names are? Some of these names are long with an underscore in them as well...

    ex: LOAD_HISTORY_END_TIMESTAMP

  12. #12
    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 2 columns, delete cells with no match

    No it doesn't matter, but you remove ALL the guesswork we're doing here by posting a usable sample workbook.

    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.

  13. #13
    Registered User
    Join Date
    06-25-2010
    Location
    Cleveland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Compare 2 columns, delete cells with no match

    Alright I took all of the values from both columns and posted them into a brand new workbook and it works just fine...I'm not sure why it wouldn't work in the current workbook?

    Thank you guys for all of your help though, it it much appreciated !

  14. #14
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Compare 2 columns, delete cells with no match

    Maybe give this a try?
    Please Login or Register  to view this content.

    Hope this helps.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    07-22-2019
    Location
    England
    MS-Off Ver
    2013
    Posts
    1

    Re: Compare 2 columns, delete cells with no match

    thank you for that Marcol it has helped

+ 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