2个回答
展开全部
在代码编辑框中输入:
Option Explicit
Function PY(TT As String) As Variant
Dim i%, temp$
PY = ""
For i = 1 To Len(TT)
temp = Asc(Mid$(TT, i, 1))
If temp > 255 Or temp < 0 Then
PY = PY & pinyin(Mid$(TT, i, 1))
Else
PY = PY & LCase(Mid$(TT, i, 1))
End If
Next i
End Function
Function pinyin(myStr As String) As Variant
On Error Resume Next
myStr = StrConv(myStr, vbNarrow)
If Asc(myStr) > 0 Or Err.Number = 1004 Then pinyin = ""
pinyin = Application.WorksheetFunction.VLookup(myStr, [{"吖","A";"八","B";"嚓","C";"搭","D";"蛾","E";"发","F";"噶","G";"铪","H";"击","J";"咔","K";"垃","L";"妈","M";"拿","N";"噢","O";"啪","P";"七","Q";"然","R";"仨","S";"他","T";"挖","W";"夕","X";"压","Y";"座","Z"}], 2)
End Function
关闭VB窗口。
EXCEL技巧——导出汉字姓名首字母
http://jingyan.baidu.com/article/19192ad831396ae53f57075d.html
Option Explicit
Function PY(TT As String) As Variant
Dim i%, temp$
PY = ""
For i = 1 To Len(TT)
temp = Asc(Mid$(TT, i, 1))
If temp > 255 Or temp < 0 Then
PY = PY & pinyin(Mid$(TT, i, 1))
Else
PY = PY & LCase(Mid$(TT, i, 1))
End If
Next i
End Function
Function pinyin(myStr As String) As Variant
On Error Resume Next
myStr = StrConv(myStr, vbNarrow)
If Asc(myStr) > 0 Or Err.Number = 1004 Then pinyin = ""
pinyin = Application.WorksheetFunction.VLookup(myStr, [{"吖","A";"八","B";"嚓","C";"搭","D";"蛾","E";"发","F";"噶","G";"铪","H";"击","J";"咔","K";"垃","L";"妈","M";"拿","N";"噢","O";"啪","P";"七","Q";"然","R";"仨","S";"他","T";"挖","W";"夕","X";"压","Y";"座","Z"}], 2)
End Function
关闭VB窗口。
EXCEL技巧——导出汉字姓名首字母
http://jingyan.baidu.com/article/19192ad831396ae53f57075d.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
嗯,需要用到拼音代码,看看下面这个帖子,如果需要就注册下载好了
参考资料: http://club.excelhome.net/thread-226972-1-2.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |