+ Reply to Thread
Results 1 to 5 of 5

Delete rows based on unique combinations of 2 columns

  1. #1
    Registered User
    Join Date
    03-09-2011
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Delete rows based on unique combinations of 2 columns

    I am using Excel 2003. I need a formula or macro that can delete or identify rows that have a unique combination of cells in columns A and B, while ignoring the data in columns C, D, and E. Thanks.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,255

    Re: Delete rows based on unique combinations of 2 columns

    Here's a simple way which uses a couple of helper columns.

    In F2 (assume row1 contains column headers), put in this formula:
    Please Login or Register  to view this content.
    In G2 put in this formula:
    Please Login or Register  to view this content.
    Fill both the formulae down to the last row of data.

    Since you want to delete any combination which appears only once, filter column G by TRUE and delete the visible rows.
    Hope that helps,

    Colin

    RAD Excel Blog

  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: Delete rows based on unique combinations of 2 columns

    1) Put a formula in an empty column that "tests" the A:B values. Something along the lines of:

    M2: =($A2 & "-" & $B2 = "code1-code2")

    That's a TRUE/FALSE construct. Edit the code1-code2 to the actual two strings you're trying to match.

    2) Copy that formula down the data set to get all the TRUE/FALSE answers

    3) Highlight the column and turn on the Data > Filter > Autofilter

    4) Filter the column for FALSE

    5) Highlight and delete all the remaining visible rows

    6) Turn off the autofilter and clear the column you used
    _________________
    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
    03-09-2011
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Delete rows based on unique combinations of 2 columns

    This worked great! Thanks!!

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

    Re: Delete rows based on unique combinations of 2 columns

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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