|
楼主 |
发表于 2018-10-29 06:51
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 YZC51 于 2018-10-29 06:59 编辑
Public Function getPy$(ByVal rng$)
'汉字转拼音首字母,自定义函数:
Dim i%, pyArr, str$, ch$
pyArr = [{"吖","A";"八","B";"攃","C";"咑","D";"妸","E";"发","F";"旮","G";"哈","H";"丌","J";"咔","K";"垃","L";"妈","M";"乸","N";"噢","O";"帊","P";"七","Q";"冄","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"}]
str = Replace(Replace(rng, " ", ""), " ", "") '去空格和Tab
For i = 1 To Len(str)
ch = Mid(str, i, 1)
If ch Like "[一-龥]" Then '如果是汉字,进行转换
getPy = getPy & Application.Lookup(ch, pyArr)
Else
'getPy = getPy & UCase(ch) '如果不是汉字,直接输出
End If
Next
End Function '原帖地址:http://club.excelhome.net/thread-1422261-1-1.html
|
评分
-
3
查看全部评分
-
|