Thread: [Solved] Removing duplicates
View Single Post
 
Old 05-25-2015, 08:43 PM
excelledsoftware excelledsoftware is offline Windows 8 Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Quote:
Originally Posted by Bruno Campanini View Post
No concerns at all!
I just noted the bug you mentioned and the non-ability of my code to discover
names like:
Juan Carlos Primero -- Juan Primero Carlos
aa bb cc dd ee ff gg -- ff gg cc aa bb ee dd
and so on.
Then this new code:
=========================
Public Sub Test()
Dim k As Long, Split_1, Split_2
Dim h, i, j, n, SR As Range
Set SR = [Sheet1!A2:A26]
k = 1
For Each i In Range(SR(1), SR(SR.Count - 1))
k = k + 1
Split_1 = Split(i, " ")
For Each j In Range(i(k), SR(SR.Count))
Split_2 = Split(j, " ")
If UBound(Split_1) = UBound(Split_2) Then
k = 0
For Each h In Split_1
For Each n In Split_2
If h = n Then
k = k + 1
End If
Next
If k = UBound(Split_1) + 1 Then
MsgBox i & " " & j & vbCrLf & _
i.Address & " " & j.Address
End If
Next
End If
Next
k = 1
Next
End Sub
======================

Your opinion would be much appreciated

Bruno
I would be happy to lend my opinion. Everyone has their own coding style and I can see you have your own. I will say that the variable names are very difficult to understand but they work for you and if you are the only person that needs to understand your code you are just fine with that.

I absolutely love how you used the Split function to extract out the first and last name. Brilliant I of course used 2 mids but it would have been much easier to use your method.

The first code fixed the issue it displayed a msgbox identifying the duplicates. The next code went a step further by deleting the entry right out and not actually deleting the entire row (Good call on that) the only issue I ever have with code deleting data is if there was some reason the user needed to validate what the code did. I am confident that your code works but users may want to see the data to delete before they actually do so. I learned a good amount from your code and the techniques you did. The last bit of feed back is to place any code in the code brackets. use [ then "code" then another ] without the quotes then to end your code tag use [ then /code then antoher ] This is very very important as it will maintain your indentation and make things more consistent.

Keep up the great work.

Thanks
Reply With Quote