remove duplicates in a string regardless of its position in string

unlike my previous question,

i have also another file which has data like this in cell  025w@52/11711/89wB  i want to remove all duplicates and retain only unique values
so the desired correct result from the above string should be 0@789B

I would appreciate, help with built in formula and if not possible with formula, then UDF

or both of them if easy.

thanks.
LVL 6
FloraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zalazarCommented:
Please insert the following code into a VBA module.

Function RemoveDuplicateChars(rCells As Range) As String
  Dim sValue As String, sPos1 As String, sReturn As String
  Dim i As Integer, j As Integer, vCounter As Integer, vFound As Integer
  Dim aChars(99, 1)

  sValue = rCells.Value
  vCounter = 1

  For i = 1 To Len(sValue)
    sPos1 = Mid(sValue, i, 1)
    
    vFound = 0
    For j = 1 To 99
      If aChars(j, 0) = sPos1 Then
        aChars(j, 1) = 1
        vFound = 1
        Exit For
      End If
    Next
    
    If vFound = 0 Then
      aChars(vCounter, 0) = sPos1
      aChars(vCounter, 1) = 0
      vCounter = vCounter + 1
    End If
  Next
  
  For i = 1 To 99
    If aChars(i, 1) = 0 Then
      sReturn = sReturn & aChars(i, 0)
    End If
  Next

  RemoveDuplicateChars = sReturn
End Function

Open in new window


If the data is in cell A1 then use this formula in B1.
=RemoveDuplicateChars(A1)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ElrondCTCommented:
Function RemoveDupChars(strTest As String) As String
    Dim strAlter, strChar  As String
    Dim iChar As Integer
    strAlter = strTest
    iChar = 1
    While iChar < Len(strAlter)
        strChar = Mid(strAlter, iChar, 1)
        If InStr(iChar + 1, strAlter, strChar, vbTextCompare) > 0 Then
            strAlter = Replace(strAlter, strChar, "")
        Else
            iChar = iChar + 1
        End If
    Wend
    RemoveDupChars = strAlter

End Function

Open in new window

0
FloraAuthor Commented:
thank you guys
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.