0

I have written this code to remove non European chrs appearing as a unicode and change them to their European equivalent. The formula works but the result is not appearing in the cell. Can you help?

Function UniChrLatin(Rg As Range) As String
    Dim xStr As String
    Dim I As Integer
    xStr = Trim(Rg.Value)
    KeepChrs = Left(xStr, 0)
    For I = 2 To Len(xStr)
        If (Mid(xStr, I, 2)) = "\u" Then
            Readcode = (Mid(xStr, I, 6))
            CorrectUnicode = Replace(Readcode, "\u", "U+")
            NormalLetter = Application.WorksheetFunction.VLookup(CorrectUnicode, Worksheets("Unicode").Range("A1:E1000"), 5, False)
            NormalLetter2 = Mid(NormalLetter, 2, 1)
            xStr = KeepChrs & Replace(xStr, (Mid(xStr, I, 6)), LCase(NormalLetter2))
            Debug.Print xStr
            
        Else
            xStr = xStr
        End If
    Next
End Function

So the initial ZonguldakK\u00f6m\u00fcrspor

Appears correctly as ZonguldakKomurspor in Debug.print

but in the cell it does not display I'm sure it is a simple tweak.

TobyPython
  • 85
  • 7

1 Answers1

1

Very simple tweak, just pass the result back through the header:

UniChrLatin = xStr
Gary's Student
  • 95,722
  • 10
  • 59
  • 99