Reputation: 1
I almost found what I was wanting:
How do I remove duplicate values in a cell seperated with a /?
...but following on from this I wonder if it can be modified to remove only consecutive duplicates, rather than all duplicates. (I am referring to the answer by Kev spitz).
E.G, 1-1-3-4-2-2-2-2-5-2-1 would currently return 1/3/4/2/5
but I'd want it to return 1-3-4-2-5-2-1
I have looked at modifying the user defined function but to be honest it's too much for my limited ability :)
Appreciate any help.
Thanks
Upvotes: 0
Views: 1137
Reputation: 96753
Consider:
Public Function LJays(sIn As String) As String
ary = Split(sIn, "-")
LJays = ary(0)
For i = LBound(ary) + 1 To UBound(ary)
If ary(i) <> ary(i - 1) Then
LJays = LJays & "-" & ary(i)
End If
Next i
End Function
Upvotes: 1