Skip to content

Instantly share code, notes, and snippets.

Created Jul 11, 2021
What would you like to do?
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
If dictionary.Count > 0 Then
RemoveDupeWords = Join(dictionary.keys, delimiter)
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