+ Reply to Thread
Results 1 to 8 of 8

Remove duplicates

  1. #1
    Registered User
    Join Date
    03-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Remove duplicates

    So lets say I have a spread sheet like this, the | will mean the column line -

    1 | 12 | bla bla bla
    2 | 13 | bla bla bla
    3 | 1 | bla bla bla
    4 | 14 | bla bla bla
    5 | 15 | bla bla bla
    6 | 2 | bla bla bla

    So I want a way to automatically remove the line that is 3 | 1 | bla bla bla, and 6 | 2 | bla bla bla because the 1 and the 2 in the 2nd column had already been used in the first column.

    How can I do this? I could have the #s in the first column on a different SS altogether but need a way for it to go through that 2nd column and delete the entire row if the # is a duplicate from 1st column.

    Please Help

  2. #2
    Registered User
    Join Date
    03-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Help removing duplicates

    Maybe this is an easier way to ask the question. I have SS that has ticket numbers in column A. I have a 2nd SS that is the same. I want to automatically remove any rows in the first spreadsheet that start with the same ticket # as in column A in the 2nd SS.

  3. #3
    Registered User
    Join Date
    12-28-2009
    Location
    São Paulo, Brazil
    MS-Off Ver
    Excel 2010
    Posts
    71

    Re: Help removing duplicates

    Hi.

    see if this code could do what you want


    Please Login or Register  to view this content.
    Osvaldo

  4. #4
    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: Help removing duplicates

    Or without a loop, assuming you have headers in row 1
    Please Login or Register  to view this content.

    Hope this helps

    Hope this helps
    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.

  5. #5
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Help removing duplicates

    hi Marcol,

    I haven't tried your code, but wouldn't it be safer if you stated that only visible cells should be deleted?
    For example:
    Please Login or Register  to view this content.
    Notes:
    1. I haven't error handling which may be needed in case there are no visible cells after the autofilter is applied.
    2. If the OP has large datasets, it would be worth sorting the data by your helper column before deleting to prevent any chance of the limitations of specialcells causing issues (see http://www.rondebruin.nl/specialcells.htm).

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  6. #6
    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: Help removing duplicates

    @ Rob
    Thought I did that by returning "" or "Delete" in the temporary helper column "D". Hence "<>"
    Maybe not enough beer, the problem might be if data starts in row 1 and this is not a header row.

  7. #7
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Remove duplicates

    lol, it would seem that it's a case of not enough beer for me

    hmmm, interesting, I've tried the code now & I didn't realise that the code would work like that (with only the visible rows being deleted, even though the entire range is named in the .delete statement), but it seems to...

    Thanks, I've learnt something new today

    Rob

  8. #8
    Registered User
    Join Date
    03-04-2011
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Remove duplicates

    Thanks for this.. Going to try it 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