+ Reply to Thread
Results 1 to 7 of 7

Delete Duplicate Rows - Mult. Col.

  1. #1
    Registered User
    Join Date
    06-02-2010
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    22

    Delete Duplicate Rows - Mult. Col.

    Hello All,

    I have been searching through out the forums and found countless threads on deleting duplicate rows. The main issue is that most of these are for just 2 columns. I am trying to formulate a macro to compare several columns and rows. I want to have the macro look through the data and if all cells in the rows (not just ‘A and B’ or ‘C and D’) are the same it will delete the duplicates leaving just one unique row of that data.

    I have been playing with the code from these two post but am still unable to get it to work for multiple columns.

    http://www.excelforum.com/excel-prog...-row-rows.html

    http://www.excelforum.com/excel-prog...-only-one.html

    Thank you for any help,
    Tay

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Delete Duplicate Rows - Mult. Col.

    Hello Taya,

    It would be easier to code a solution using your workbook. Attach the workbook with your next post.

    To Attach a File:
    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-02-2010
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Delete Duplicate Rows - Mult. Col.

    Hello Leith Ross,

    Thank you for taking a look at this. This is a mock of my data. The first sheet has all the data (for the sample) and the second sheet has what I hope to get out of the macro. This sheet has only unique rows of data. Again the duplicates are deleted but one row of the duplicates is left.

    Let me know if you would like any further explanation.

    Thank you for your time,
    Tay
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-04-2010
    Location
    SLC, UT
    MS-Off Ver
    Excel 2003, 2007
    Posts
    31

    Re: Delete Duplicate Rows - Mult. Col.

    I wrote this a couple of years ago. It has worked very well for me, but has two basic assumptions: You must have either the top-left-most cell of your data table or the enitre data table selected, and each duplicate line must be adjacent to each other in the table.

    When the user form appears, you can select your outcome from the drop-down list and click continue.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-02-2010
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Delete Duplicate Rows - Mult. Col.

    aclawson,

    Thank you for the input, the document you provided is very interesting and has very nice features for analyzing data. But the only issue is that my duplicates are not adjacent to each other. The real document I am working with has thousands of lines of data, in addition to several columns.

    Thank you for the help aclawson, leith ross, and anyone else.
    Tay
    Last edited by taya; 08-04-2010 at 04:33 PM.

  6. #6
    Forum Contributor
    Join Date
    09-09-2009
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    185

    Re: Delete Duplicate Rows - Mult. Col.

    Aclawson,

    I am messing with your code a littl bit. It's really nice. I am looking for somrthing very similar to this, but I was curious if I can just select 1 column of data. Then when it deletes the duplicates it will delete the whole row not just those cells. Any ideas? Also, Instead of deleting, I would love it if it hid the rows of duplicates instead of deleting. Any ideas on that as well?

    Thank you.

  7. #7
    Registered User
    Join Date
    08-04-2010
    Location
    SLC, UT
    MS-Off Ver
    Excel 2003, 2007
    Posts
    31

    Re: Delete Duplicate Rows - Mult. Col.

    wmn,

    Sorry for the slow response. I typically get very busy at work the first half of the month. Your question is very doable, but would take some code modifications, and perhaps an additional field in the userform, thus preserving the multi-outcome functionality of the macro code.

    Until I can re-visit the code at that level, though, a simple code to accomplish your qustion would be:
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 08-18-2010 at 10:52 PM. Reason: Added Code Tags

+ 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