Remove Duplicates from Spreadsheet

zalik22

Board Regular
Joined
Dec 14, 2010
Messages
122
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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