-
-
Save ndthanh/d234b8076762234736182efa66f37f6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function RemoveDupeWords(text As String, Optional delimiter As String = " ") As String | |
Dim dictionary As Object | |
Dim x, part | |
Set dictionary = CreateObject("Scripting.Dictionary") | |
dictionary.CompareMode = vbTextCompare | |
For Each x In Split(text, delimiter) | |
part = Trim(x) | |
If part <> "" And Not dictionary.Exists(part) Then | |
dictionary.Add part, Nothing | |
End If | |
Next | |
If dictionary.Count > 0 Then | |
RemoveDupeWords = Join(dictionary.keys, delimiter) | |
Else | |
RemoveDupeWords = "" | |
End If | |
Set dictionary = Nothing | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment