I'm trying to cut duplicates from a string i have.
The string looks like this:
word-1\word-2\word-3\word-3\word-3\word-3 |
---|
And I wish it look like this: (without the duplications).
word-1\word-2\word-3 |
---|
So far I thought of put the string into an array and split to items by \ . I don't really know how I suppose to cut the duplications. Moreover, I don't know how many duplicates gonna be.
This is what I got so far:
Sub Split_and_remove()
' split items on \
Dim item As String, newItem As String
Dim items As Variant, newItems As Variant
item = Sheet1.Range("A1").Value2
items = Split(item, "\")
newItems = items(0) + "\" + items(1) + "\" + items(2)
Sheet1.Range("A4").Value2 = newItems
End Sub
Thanks!