- Oct 9, 2015
- Office Version
Hi, I am trying to remove duplicate letters from cells, however the code below works fine on letters but when there are numbers involved it doesn't end well. What I would like to do is remove all duplicate letters from a cell even if there are numbers present. Can someone help with this.
Sub LetterDupes() Dim Str As String, xChar As String, MyStr As String, x As range, Rng As range Set xDic = CreateObject("Scripting.Dictionary") Set Rng = ActiveSheet.UsedRange For Each x In Rng Str = x For i = 1 To VBA.Len(Str) xChar = VBA.Mid(Str, i, 1) If xDic.Exists(xChar) Then Else xDic(xChar) = "" MyStr = MyStr & xChar End If Next Next x Rng = MyStr End Sub
|CC1, CC32, CC33, CC18|
|C1, C32, C33, C18|