remove duplicate rows in excel

Anirban Majumdar

New Member
Joined
Aug 10, 2017
Messages
6
Can anyone please help me the way to remove second duplicate rows in excel ?
For example: In below need to remove rows with red font.

[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]Details[/TD]
[TD="class: xl65, width: 64"]Num#[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]AAA[/TD]
[TD="class: xl66, align: right"]62600173[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 64"]AAAB[/TD]
[TD="class: xl69, align: right"]62600173[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]CCC[/TD]
[TD="class: xl66, align: right"]62600021[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 64"]CCCB[/TD]
[TD="class: xl69, align: right"]62600021[/TD]
[/TR]
</tbody>[/TABLE]

Anirban
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Can anyone please help me the way to remove second duplicate rows in excel ?
For example: In below need to remove rows with red font.

[TABLE="width: 128"]
<tbody>[TR]
[TD="class: xl65, width: 64"]Details[/TD]
[TD="class: xl65, width: 64"]Num#[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]AAA[/TD]
[TD="class: xl66, align: right"]62600173[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 64"]AAAB[/TD]
[TD="class: xl69, align: right"]62600173[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]CCC[/TD]
[TD="class: xl66, align: right"]62600021[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 64"]CCCB[/TD]
[TD="class: xl69, align: right"]62600021[/TD]
[/TR]
</tbody>[/TABLE]

Anirban

do you need a dynamic solution? if not, highlight the table, go to Data -> Remove Duplicates, check My data has headers, check Num# and press OK.
 
Upvote 0
Hi Anirban,

Welcome to MrExcell!!

Assuming the numbers are in Col. B and the data is how you show it here, try this while on the sheet with the data (though initially on a copy of your data as the results cannot be undone if they're not as expected):

Code:
Option Explicit
Sub Macro1()

    Dim lngMyRow As Long
    Dim lngLastRow As Long
    
    Application.ScreenUpdating = False
    
    lngLastRow = Range("A:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    
    For lngMyRow = lngLastRow To 2 Step -1
        If Range("B" & lngMyRow) = Range("B" & lngMyRow - 1) Then
            Rows(lngMyRow).EntireRow.Delete
        End If
    Next lngMyRow
    
    Application.ScreenUpdating = True

End Sub

Regards,

Robert
 
Upvote 0
Can you use something like this? =IFERROR(INDEX($B$2:$B$5,MATCH(0,COUNTIF($D$1:$D1,$B$2:$B$5),0))," "). Place Unique in D1. Use Cntrl+Shift+Enter. Copy down.

details Num Unique
AAA 62600173 62600173
AAAB 62600173 62600021
CCC 62600021
CCCB 62600021
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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