Automatically Delete Duplicate Cell Rows which have a unique

nischal4487

New Member
Joined
Nov 21, 2007
Messages
45
Hi,

I frequently receive a dump of excel with huge date. However, in column A I have unique values (eg:- Employee id) which are duplicated several times which I have delete manually. everytime.
Could you please help me to give a query or formula or any guidance to automatically have rows which have the duplicates only one Id remain?

Advance thanks for your support
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Dont know what version of excel you have but under the data option in nwere versions there is an option to delete Duplicate rows
1652348144780.png
 
Upvote 0
You can use it to record a Macro
VBA Code:
Sub dup2()
'
' dup2 Macro
'
    ActiveSheet.Range("$A$1:$E$5").RemoveDuplicates Columns:=1, Header:=xlYes
End Sub

Amend range as required, Columns number 1 + column A to use a s reference for finding and deleting your duplicate rows use whichever column has ID in it, assign button to macro, voila
 
Upvote 0
VBA Code:
Sub dup2()
'
' dup2 Macro
'
ActiveSheet.Range("$A$1:$E$5").RemoveDuplicates Columns:=1, Header:=xlYes
End Sub
Amend range as required, Columns number 1 + column A to use a s reference for finding and deleting your duplicate rows use whichever column has ID in it, assign button to macro
Hi Kerry,

Thank you so much for your reply. I know I am sounding dunce , but can you please let know where do I input the code you have provided.

Thanks Again.
 
Upvote 0
Ok since it is your first time please be aware running VBA code there is no go back option if you make a mistake hence it is always best to run on a copy of your workbook / sheet when testing

Open your workbook, Press Alt+F11
This will open your VBA editor screen
1652351353754.png

Select the Sheet
past the code
1652351604035.png


Then run the code

there are plenty of walkthroughs more detailed than this on the web.
 

Attachments

  • 1652351446296.png
    1652351446296.png
    20.5 KB · Views: 3
Upvote 0
Thanks so much Kerry this worked, Is there any code that can have entire duplicated rows deleted rather just making the duplicated cells blank.Kindly help
 
Upvote 0
replace the code with this, i am assuming the ID is in column A and that once you find a duplicate you want it deleted

VBA Code:
Sub RemoveDuplicateRows()

Dim Rng As Range
Dim x As Long
Set Rng = Range("A1", Range("A" & Rows.Count).End(xlUp))
x = Rng.Rows.Count

For x = x To 1 Step -1
    With Rng.Cells(x, 1)
       If WorksheetFunction.CountIf(Rng, .Value) > 1 Then
                  .EntireRow.Delete
       End If
     End With
Next x

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,078
Latest member
skydd

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