Remove Duplicates from Spreadsheet

zalik22

Board Regular
Joined
Dec 14, 2010
Messages
111
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to use VB Code to remove duplicates from a spreadsheet based off a column header of "Empl ID". I want the duplicates to be deleted.

Thanks!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Excel has a built-in "Remove Duplicates" functionality that can do this.
It can be found on the Data menu, on the "Data Tools" ribbon.
 
Upvote 0
The number of rows of data is not fixed and it is part of a macro I am building. Thanks!
 
Last edited:
Upvote 0
The number of rows does not need to be pre-determined. You can apply it to the whole column.
And if you use the Macro Recorder as you record yourself using this functionality, you can get most of the code you need.
Here is a cleaned-up version that removes duplicates from column M:
Code:
    Columns("M:M").RemoveDuplicates Columns:=1, Header:=xlYes
 
Upvote 0
The number of rows does not need to be pre-determined. You can apply it to the whole column.
And if you use the Macro Recorder as you record yourself using this functionality, you can get most of the code you need.
Here is a cleaned-up version that removes duplicates from column M:
Code:
    Columns("M:M").RemoveDuplicates Columns:=1, Header:=xlYes

So this basically removes duplicates based on column M? Thanks!
 
Upvote 0
That only one column is being considered when determining duplicates.
The "Remove Duplicates" functionality can take multiple columns into account, if you like (i.e. only consider a duplicates if multiple columns match).
 
Upvote 0

Forum statistics

Threads
1,215,149
Messages
6,123,311
Members
449,095
Latest member
Chestertim

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