Macro212

New Member
Joined
Aug 29, 2018
Messages
11
Hello, I would like to use a VBA code to remove the duplicates in Sheet 1 column A and then copy and paste the list (without duplicates) to Sheet 2 column A.

Example:

Sheet 1

Column A:
John
Jim
Alice
John
Jim
Tim
Tim
Tom

So I want the VBA code to remove the duplicates and paste the new list without duplicates. I have provided the example below.

Sheet 2

Column A:
John
Jim
Alice
Tim
Tom
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Why not just use Excel's built in "Remove Duplicates" functionality?
It can be used in VBA too.
To get the code, you can just turn on the Macro Recorder, and record yourself doing it manually.
If you need helping cleaning up the code afterwards (or making it more dynamic), paste your code here along with letting us know what you need to add to it.
 
Upvote 0
The data in the column is active. It is linked to another sheet. So the "Remove Duplicates" functionality doesnt work when the data in the column is linked other cells. And I want the cleaned up list in a different sheet.
 
Upvote 0
Please explain exactly what you mean by "linked".
 
Upvote 0
How about
Code:
Sub Macro212()
   Dim Cl As Range
   Dim Ws As Worksheet
   
   Set Ws = Sheets("Sheet1")
   With CreateObject("scripting.dictionary")
      .CompareMode = 1
      For Each Cl In Ws.Range("A1", Ws.Range("A" & Rows.Count).End(xlUp))
         If Cl.Value <> "" Then .Item(Cl.Value) = Empty
      Next Cl
      Sheets("sheet2").Range("A1").Resize(.Count).Value = Application.Transpose(.Keys)
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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