Remove duplicate rows

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
Hi all,

Can someone help with me with a macro to remove duplicate rows based on an input in column E?
Heres some sample data below:

Excel Workbook
ABCDEFGH
3NameDbJob NumberAddessExchangeRequired DateSearch ResultsComments
4blahblahblahblahMYP35222*24/08/2011*blahblah
5blahblahblahblahMYP35222*24/08/2011*blahblah
6blahblahblahblahMYP35222*24/08/2011*blahblah
7blahblahblahblahMYP35222*24/08/2011*blahblah
8blahblahblahblahMYP35222*24/08/2011*blahblah
create_report 1


Basically I need to be left with only 1 row of data where duplicate code appears in column E. In the example above there is a header row which starts in row 3. Iif i run the macro on the sample above i should be left with a header row plus 1 row as the other 4 are duplicates. The start row (row 3) is always the same but the data set can change to a different end row day on day so i need the macro to run until it hits the last row.

Thanks for any help with this.

Edit** the screenshot above shows that the cells contain a * at the end of the reference number i need to remove duplicates in my actual spreadsheet there is no * not sure how this got there.

Thanks
 
Sorry, I missed the bit about column B

Code:
Sub NoDup()
Dim LR As Long, i As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
For i = LR To 4 Step -1
    If WorksheetFunction.CountIf(Range("E4:E" & i), Range("E" & i).Value) > 1 Then Rows(i).Delete
Next i
On Error Resume Next
Columns("E").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
LR = Range("E" & Rows.Count).End(xlUp).Row
Columns("A").Insert
Range("A3").Value = "Cst Name"
For i = 4 To LR
    Range("A" & i).Value = Left(Range("D" & i).Value, Len(Range("D" & i).Value) - 2) & Left(Range("C" & i).Value, 2)
Next i
End Sub
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
VoG,

works brilliantly, thanks for your help :)
 
Upvote 0
hi,

if you are using excel 2007 or further version than you can use the default function for removing duplicate rows. Select your data and go to Data menu and select "Remove duplicates" and then select the columns in which you want to delete the duplicate rows. kindly revert me back if its working.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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