+ Reply to Thread
Results 1 to 5 of 5

Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

  1. #1
    Registered User
    Join Date
    09-25-2013
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

    Hi,

    I will appreciate your help on my project. As shown in the attached file, I have data from Columns A to G. I want to do the following:

    1. Look for duplicates in all column A
    2. For each duplicate found in column A, check if all values in columns B, C and D are also duplicates (The condition is all 4 columns must have the same values)
    3. If the condition in (2) is satisfied, compare column E for all the rows; select the row with the minimum value in column E, and delete the other rows.

    For example:

    A B C D E F G

    Row1:Test01 100 Class 1 1 80.67 6.47 145
    Row2:Test01 50 Class 1 3 80.25 6.71 598
    Row3:Test01 100 Class 1 1 77.72 6.62 110

    Since Rows 1 and 3 have the same values in columns A, B, C and D; and Row3 value in column E is less than Row1 value (77.72<80.67); Delete Row1

    Results

    A B C D E F G

    Row2:Test01 50 Class 1 3 80.25 6.71 598
    Row3:Test01 100 Class 1 1 77.72 6.62 110

    Thank you for your help!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

    I think I captured everything. The reason I had it do 2 loops was because of the random potential for deletions. I figured this way the deletion wouldn't mess up the loop.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-25-2013
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

    Thank you for the quick response. I works like magic. I will spend some time to understand the code.

    Thanks!

  4. #4
    Registered User
    Join Date
    09-25-2013
    Location
    Arizona, USA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

    I have finished running the code and it works perfect. I have a little concern though. Instead of deleting the entire row, can it be modified to delete only the data? I have some other data on the worksheet that I dont want to delete

    Thanks

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro To Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel

    Thats an easy one.

    Change:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Note: it would have been best to just do this within the first loop and disregard the second loop. However I don't want to take the time to go back and error check the first loop.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to find duplicates, concatenate cells, then delete old duplicates
    By givemepuppies in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 03-04-2016, 02:43 AM
  2. [SOLVED] Find duplicates rows, sum cells then remove duplcate rows
    By Wagstaff in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-22-2013, 09:37 AM
  3. Replies: 1
    Last Post: 05-06-2013, 06:28 AM
  4. Replies: 13
    Last Post: 08-23-2011, 11:00 AM
  5. Replies: 2
    Last Post: 06-27-2006, 04:00 PM

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