+ Reply to Thread
Results 1 to 6 of 6

Delete duplicate rows

  1. #1
    Registered User
    Join Date
    12-14-2011
    Location
    Rochester, MN, USA
    MS-Off Ver
    Office 2010 and 365
    Posts
    54

    Delete duplicate rows

    Hello All,
    Earlier today TMShucks had provided me with the following code. (Thank you again TMS for your help!)
    This code compares A1 to B1 and if equal, copies A1&B1 to Sheet2 and then deletes row1 from Sheet1.
    It also comes back with a handy msg box that tells me how many duplicates were removed, and how many unique records remain.

    Please Login or Register  to view this content.
    I now need to be able to adapt this code to compare rows. Example, does A1 & B1 = A2 & B2. If so, copy row 2 to Sheet2 then delete row 2 from Sheet1.
    I also need to have this work from TOP to BOTTOM as the the first line will contain information that I want to keep.
    The current code (above) works from the bottom up. (would also like to get that working from TOP down if possible)
    Since I have no idea how the above code works (was a complete re-write of my code) I can not begin to try anything to get this to work. I already tried getting it to run from top down and failed miserably.

    Here is an example workbook to work from that includes the above code, and my original code that worked from TOP to bottom. (Very different code)
    Also does not contain all columns as that has sensitive data. :-)
    Del_Dup Test List.xls

    Any more help would be greatly appreciated!

    Thanks Again!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete duplicate rows

    Just wanted to clarify - I see data in this format -
    MFG_NAME MFG_ID
    10 MIL 10MIL
    10MIL 10MIL
    I would consider this as non-duplicate. Would you consider this as a duplicate?
    Last edited by arlu1201; 01-08-2012 at 10:45 AM.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    12-14-2011
    Location
    Rochester, MN, USA
    MS-Off Ver
    Office 2010 and 365
    Posts
    54

    Re: Delete duplicate rows

    Quote Originally Posted by arlu1201 View Post
    Just wanted to clarify - I see data in this format -
    MFG_NAME MFG_ID
    10 MIL 10MIL
    10MIL 10MIL
    I would consider this as non-duplicate. Would you consider this as a duplicate?
    Correct... That is a NON duplicate.
    Actually the duplicate 10MIL side-by-side will have been deleted by the original code that compare A1-B1.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete duplicate rows

    Ok, so ideally you will be running that first bit of code to compare A1-B1. And then the 2nd code to compare A1&B1 with A2&B2. Right?

  5. #5
    Registered User
    Join Date
    12-14-2011
    Location
    Rochester, MN, USA
    MS-Off Ver
    Office 2010 and 365
    Posts
    54

    Re: Delete duplicate rows

    Quote Originally Posted by arlu1201 View Post
    Ok, so ideally you will be running that first bit of code to compare A1-B1. And then the 2nd code to compare A1&B1 with A2&B2. Right?
    That is correct!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete duplicate rows

    Use this code - I ran it myself and didnt find any duplicates in the sample data that you provided. This code will cut paste the 2nd line of each pair that is duplicate to the 2nd sheet and then once all the rows are done, it will sort the page, so that the blanks go off. (Blanks derived from the cut paste).
    Please Login or Register  to view this content.

+ 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