0

I have an excel file with Name column which is in different language.I need to convert this names into Standard English language.

Example:

HỒ ĐĂNG TẤN has to be converted to HO DANG TAN.

NGUYỄN ĐỨC KIÊN - NGUYEN DUC KIEN

ĐOÀN THỊ THANH THẢO- DOAN THI THANH

4

2 回答 2

6

第 1 步:打开 Microsoft Visual Basic for Applications 窗口。

第二步:点击插入->模块,在模块窗口中输入以下宏。

Function StripAccent(thestring As String)
Dim A As String * 1
Dim B As String * 1
Dim i As Integer

Const AccChars= "ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ"
Const RegChars= "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy"

For i = 1 To Len(AccChars)
A = Mid(AccChars, i, 1)
B = Mid(RegChars, i, 1)
thestring = Replace(thestring, A, B)
Next
StripAccent = thestring
End Function

第 3 步:然后转到空白单元格并将公式粘贴到单元格中:
=CheckStringCHAR(InString)
例如=CheckStringCHAR("ù"),或=CheckStringCHAR(A2)

字符列表并不详尽。更多信息请访问http://en.wikipedia.org/wiki/List_of_Latin-script_letters#Letters_with_diacritics

于 2013-06-19T07:04:11.003 回答
0

只是为了好玩,下面是一个更有效的函数版本,它在上面粘贴的网络上进行循环作为答案。

样本测试结果(10,000 个字符字符串的 100 个循环)。时间是每次调用的毫秒数,从 QueryPerformanceTimer 中获取。

旧:最小值:57.6 毫秒,平均值:65.4 毫秒

新:最小值:22.1 毫秒,平均值:24.4 毫秒

性能改进来自于在每次替换时不创建字符串的新副本,而是使用 Mid$ 语句就地替换字符。

Public Function StripAccent(ByVal txt As String) As String
    Dim i As Long, j As Long, n As Long
    Const c1 = "ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ"
    Const c2 = "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy"
    n = Len(c1)
    For i = 1 To n
        j = 0
        Do
            j = InStr(j + 1, txt, Mid$(c1, i, 1), vbBinaryCompare)
            If j > 0 Then Mid$(txt, j, 1) = Mid$(c2, i, 1) Else Exit Do
        Loop
    Next
    StripAccent = txt
End Function
于 2015-04-20T12:36:44.853 回答