delete all duplicates except one

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
790
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:
Just a little reminder, cells B12, B14, B16, B18, B20, B22, and B24 are drop down lists, that's why it's imperative for me to just clear the contents.
 

Attachments

  • 20200124_040819.jpg
    20200124_040819.jpg
    217.7 KB · Views: 8
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Just a little reminder, cells B12, B14, B16, B18, B20, B22, and B24 are drop down lists, that's why it's imperative for me to just clear the contents.


Try this

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
 
Upvote 0
if you still get an error on pc go to your VBA screen and click tools > references
make sure your "Microsoft Excel Object Library" (and maybe your office library) are ticked.
 
Upvote 0
Thank you for all your responses. I'll try the code DanteAmor suggested and update yall
 
Upvote 0
if you still get an error on pc go to your VBA screen and click tools > references
make sure your "Microsoft Excel Object Library" (and maybe your office library) are ticked.
I'll take note of that.
 
Upvote 0

Forum statistics

Threads
1,226,730
Messages
6,192,702
Members
453,748
Latest member
akhtarf3

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