delete all duplicates except one

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
756
Office Version
  1. 365
  2. 2010
im trying to delete all duplicates based on an ID in column F, except one (it doesn't matter which one I keep...ie it could be the first one, could be the last duplicate).

trying to do this with a macro.
 
Last edited:
I hope people are still out here. I'm having very hard time finding out the code for this one guys. Picture is attached to understand it better. This is the formula that I used before which was given by @DanteAmor. It worked before but right now it doesn't. I hope someone can help me.

This is the code:
VBA Code:
Sub test()
Dim i As Long, f As Range
For i = 24 To 14 Step -2
Set f = Range("B12:B" & i - 2).Find(Range("B" & i), , xlValues, xlWhole)
If Not f Is Nothing Then Range("B" & i).ClearContents
Next
End Sub

Duplicate Macro.jpg
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try this

VBA Code:
Sub test2()
  Dim i As Long
  For i = 24 To 12 Step -1
    If WorksheetFunction.CountIf(Range("B12:B" & i), Range("B" & i)) > 1 Then Range("B" & i).ClearContents
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,654
Latest member
mememe101

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