Forum Discussion
Cartire2000
Jul 27, 2022Copper Contributor
Help with removing both values in a duplicate
I'm having a hard time with removing spurious data from a sheet. We have hundreds of thousands of unique codes that were accidently merged with incorrect data. This was done by a different party and thus we cant simply reverse the error. I have the incorrect values and know how to find the duplicates, but I dont want to remove just one entry, I want to remove both the original and the duplicate value.
Is there a way I can do this without having to go line by line?
Scripting.Dictionary is for Windows only, it doesn't exist on a Mac. Here is a version that should work on a Mac:
Function RemoveDupes1(pWorkRng As Range) As String 'Update by Microsoft Tech Community Dim xValue As String Dim xChar As String Dim xOutValue As String Dim xCol As New Collection Dim i As Long xValue = pWorkRng.Value For i = 1 To Len(xValue) xChar = Mid(xValue, i, 1) On Error Resume Next xCol.Add Item:=xChar, Key:=xChar Next i For i = 1 To xCol.Count xOutValue = xOutValue & xCol(i) Next i RemoveDupes1 = xOutValue End Function
4 Replies
Sort By
- mtarlerSilver ContributorHow about using =UNIQUE( range, , TRUE) function to return the values and copy and 'paste values'
- Patrick2788Silver Contributor
Are you looking to return only records appearing once?
Here's a sample data set with dupes and after with only records appearing once:
=UNIQUE(A2:C8,,1)
- Cartire2000Copper ContributorThank you, this is what I needed. My internet research was stuck on the word "duplicate" and i didnt even think about looking at it that way.
- Patrick2788Silver ContributorYou're welcome!