Keep Highlight Duplicate values shading

overbet

Board Regular
Joined
Jul 9, 2010
Messages
63
Office Version
  1. 2010
Hi,
I was wondering if anyone had any idea how accomplish this task. I have a large sheet with a lot of duplicate values Id like to remove. I used conditional formatting to highlight the dupes, but the problem is when I delete one it takes Excel a good minute to respond. There are about 1000 dupes so this is too painfully slow to do this way. I have tried turning calculation to manual which helps, but not enough its still too slow. I have tried creating a duplicate sheet -2 and highlighting them on one while deleting on the other. This also helped, but gets confusing because the highlights never go away on the -2 sheet. I would like to know if I can copy and paste the conditional formatting format that highlights them pink and then remove the conditional formatting to be left with the dupes highlighted. Maybe there is some way to sort by the conditional formatting results then i could cluster them and delete all at once? Or if someone has another possible solution to speed things up. Appreciate any help.
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I manually selected and copied the code and it included the VBA: I think that messed it up. I just tried again and used the copy code button on the interface and it left out the VBA:. I ran the code again this way and got no error.
 
Upvote 0
Ok, this will probably need some tweaking, as I've got nothing to test on, but try
VBA Code:
Sub overbet()
   Dim Ary As Variant
   Dim r As Long, c As Long
   
   Ary = Range("A1").CurrentRegion.Value2
   
   With CreateObject("scripting.dictionary")
      For c = 1 To UBound(Ary, 2)
         For r = 1 To UBound(Ary)
            If Ary(r, c) <> "" Then
               If Not .Exists(Ary(r, c)) Then
                  .Add Ary(r, c), Array(r, c)
               Else
                  If .Item(Ary(r, c))(1) > 5 Then Ary(.Item(Ary(r, c))(0), .Item(Ary(r, c)(1))) = ""
                  Ary(r, c) = ""
               End If
            End If
         Next r
      Next c
   End With
   Range("A1").CurrentRegion.Value = Ary
End Sub
 
Upvote 0
I get an error. Screen shots attached. Do i need to add a reference or select the range?
 

Attachments

  • Capture-2.PNG
    Capture-2.PNG
    5.1 KB · Views: 3
  • Capture.PNG
    Capture.PNG
    18 KB · Views: 4
Upvote 0
Oops, got one of the closing brackets in the wrong place, that line should be
Rich (BB code):
                  If .Item(Ary(r, c))(1) > 5 Then Ary(.Item(Ary(r, c))(0), .Item(Ary(r, c))(1)) = ""
 
Upvote 0
Wow that worked from what I can see it removed all the duplicates. Thank so much for your time and effort. I really appreciate it. You saved me a ton of time, eye strain and oatmeal brain Lol.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

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