Deleting Duplicates

thewiseguy

Well-known Member
Joined
May 23, 2005
Messages
1,015
Office Version
  1. 365
Platform
  1. Windows
Hi All,

In duplicating an entire row, I would like to remove the row that has LESS data than it's duplicate.

Example:

Dupe 1: data in columns A-C
Dupe 2: data in columns A-F
Action: Delete Dupe 1


Is there a way to accomplish this?

Thanks in advance!


/TWG
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
In duplicating an entire row, I would like to remove the row that has LESS data than its duplicate.
Really :confused:
It cannot be a duplicate if it has less data :confused:
Presumably something must match up otherwise how does Excel know it's a duplicate :confused:

A much clearer explanation would be useful :)
- what is contained in columns A:F?
- what is being matched eg is it Columns A:C must match the A:C in A:F or do other column combinations apply?
- please provide different examples of what makes a row eligible for deletion
 
Last edited:
Upvote 0
For the most part, I agree with @Yongle.
But, if the LESS data is based on number of cells used AND the data is sorted by Col "A"
But I'm concerned there will be too many variables for this to be efficient

Code:
Sub MM1()
Dim lr As Long, r As Long, c1 As Integer, c2 As Integer
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
 c1 = Application.WorksheetFunction.CountA(Rows(r).EntireRow.Cells)
 c2 = Application.WorksheetFunction.CountA(Rows(r - 1).EntireRow.Cells)
    If Range("A" & r).Value = Range("A" & r - 1) And _
        c1 < c2 Then
        Rows(r).Delete
        ElseIf Range("A" & r).Value = Range("A" & r - 1) And c1 > c2 Then
        Rows(r - 1).Delete
    End If
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top