【问题标题】:Displaying a UDF result [duplicate]显示 UDF 结果 [重复]
【发布时间】:2021-02-23 00:39:21
【问题描述】:

我已编写此代码以删除显示为 unicode 的非欧洲字符并将它们更改为欧洲等效字符。该公式有效,但结果未出现在单元格中。你能帮忙吗?

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

所以最初的 ZonguldakK\u00f6m\u00fcrspor

在 Debug.print 中正确显示为 ZonguldakKomurspor

但在单元格中它不显示我确定这是一个简单的调整。

【问题讨论】:

  • End Function 之前,您需要一行:UniChrLatin = xStr 让该函数返回一些内容。

标签: excel vba


【解决方案1】:

非常简单的调整,只需将结果通过标题传回:

UniChrLatin = xStr

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    相关资源
    最近更新 更多