+ Reply to Thread
Results 1 to 5 of 5

Deleting duplicate rows

  1. #1
    Registered User
    Join Date
    03-21-2007
    Posts
    13

    Deleting duplicate rows

    Hi,

    I have an excel sheet, that - post data-cleaning - has multiple rows. For example:

    A B C D E F
    Ohio 1020 Paul
    Ohio 1020 Paul
    New York 1110 Virginia
    Ohio 1020 Paul
    Ohio 1020 Paul

    Which Should ideally look like


    A B C D E F
    Ohio 1020 Paul
    New York 1110 Virginia

    All those entries for Ohio are duplicates, and I want only one row for Ohio. I have simplified the excel to understand the approach I must take - actual excel sheet has around 15/20 columns for now.

    Ideally this would be a function/procedure that I can call from multiple subroutines (at the end of data-cleaning). Tried searching for online examples and other posts in the forum, after my attempts at this fell flat on my face (I even successfully managed to delete *all* rows in the sheet, without any recovery possible, after the cleaning subroutine took 45 mins to run. Brilliant.

    Attaching a sample work sheet to illustrate. Is this even possible? Thanks..
    Attached Files Attached Files
    Last edited by Upparna; 01-31-2012 at 06:30 PM. Reason: The grammar

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,492

    Re: Deleting duplicate rows

    As it's an .xlsx file extension, I assume you're using Excel 2007 or 2010.

    If so, use Data | remove Duplicates and select columns A, C and E.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-31-2012
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Deleting duplicate rows

    There might be a faster way, but if you hold CTRL you can select more than one row that aren't in order. This will save you from deleting each row 1 by 1.

  4. #4
    Registered User
    Join Date
    01-31-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007/2010
    Posts
    10

    Re: Deleting duplicate rows

    you can just add this code and assaign a button to it

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    03-21-2007
    Posts
    13

    Re: Deleting duplicate rows

    Thanks all for your responses! I tried all these, and then tried this simple line of code - i think it works like a charm (needs more testing though):

    ActiveSheet.Range("A:M").RemoveDuplicates Columns:=Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), Header:=xlYes

    This takes care of the duplicates and retains the header.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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