获取人名拼音首字母的excel函数

用途:Palm通讯录中直接通过键盘字母调用联系人;
用法:
1.将palm软件同步到系统中,将通讯录到处成CSV文件;
2.在Excel中新建一个模块,将下面的代码复制进去,在excel界面调用HYPY函数即可。

Function HYPY(myStr As String) As String
Dim L As Integer, i As Integer
Dim GetPY As String, N As String
On Error Resume Next

myStr = StrConv(myStr, vbNarrow)
L = Len(myStr)

For i = 1 To L
If Asc(Mid(myStr, i, 1)) > 0 Or Err.Number = 1004 Then N = ""
N = Application.WorksheetFunction.VLookup(Mid(myStr, i, 1), _
[{"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"}], 2)
GetPY = GetPY & N
Next i

HYPY = GetPY
End Function

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *