Highlight Duplicates in 1 column on large data set

Nieriel

New Member
Joined
Feb 16, 2015
Messages
26
Hi All,
I am trying to highlight all duplicates within a single column (E) in Excel on a large set of data (nearly 300k rows) with columns going A-Q, my headers are in Row 1 and data starts in Row 2
I have tried to use Conditional Formatting, this works to highlight the duplicates but when I try and filter or sort it just crashes excel.
I have also found a macro online but this only highlights 1 of the duplicate values, I need both as I then need to move the entire row with the duplicates to a different sheet or workbook.
Everything I find seems to crash the spreadsheet and I end up having to close excel and start again.

Any help would be appreciated
Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This will copy the duplicates to a sheet called test2 & then delete them from the original
Code:
Sub CopyDupes()

   Dim Cl As Range
   Dim Rng As Range
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("L2", Range("L" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) Then
            .Add Cl.Value, Cl
         Else
            If Rng Is Nothing Then
               Set Rng = Union(.Item(Cl.Value), Cl)
            Else
               Set Rng = Union(.Item(Cl.Value), Cl, Rng)
            End If
         End If
      Next Cl
   End With
   Rng.EntireRow.Copy Sheets("Test2").Range("A2")
  [COLOR=#0000ff] Rng.EntireRow.Delete[/COLOR]
End Sub
If you don't want them deleted, just remove the line in blue
 
Upvote 0
Thanks both - the formula unfortunately won't work as when I copy it down all the rows it crashes due to the volume of data but the Macro seems to be working fine.
Thanks again
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,209
Members
453,023
Latest member
alabaz

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