Excel中如何用函数实现提取汉字的首字母呢,一起来研究一下吧
方法
在Excel表格输入一句话。
在键盘上敲击组合键【alt+f11】,点击【插入】命令,在下拉菜单中点击【模块】命令。
双击【模块】命令,右侧会出现编辑代码的窗口。
输入如下的函数
Function pinyin(p As String) As String
i = Asc(p)
Select Case i
Case -20360新知319 To -20284: 工意pinyin = "A"
Case -20283 To -19蒸衡经清者矿考776: pinyin = "B"
Case -19775 To -19219: pinyin = "C"
Case -19218 To -18711: pinyin = "D"
Case -18710 To -18527: pinyin = "E"
Case -18526 To -18240: pinyin = "F"
Case -18239 To -17923: pinyin = "G"
Case -17922 To -174父运商处起取支员18: pinyin = "H"
Case -17417 To -16475: pinyin = "J"
Case -16474 To -16213: pinyin = "K"
Case -16212 To -15641: pinyin = "L"
Case -15640 To -15166: pinyin = "M"
Case -15165 To -14923: pinyin = "N"
Case -14922 To -14915: pinyin = "O"
Case -14914 To -14631: pinyin = "P"
Case -14630 To -14150: pinyin = "Q"
Case -14149 To -14091: pinyin = "R"
Case -14090 To -13319: pinyin = "S"
Case -13318 To -12839: pinyin = "T"
Case -12838 To -12557: pinyin = "W"
Case -12556 To -11848: pinyin = "X"
Case -11847 To -11056: pinyin = "Y"
Case -11055 To -2050: pinyin = "Z"
Case Else: pinyin = p
End Select
End Function
Function getpy(str)
For i = 1 To Len(str)
getpy = getpy & pinyin(Mid(str, i, 1))
Next i
End Function
关闭编辑函数界面,回到Excel表格编辑界面,在表格里面输入函数【=getpy(A1)】。
按回车键,效果如图所示。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 951076433@qq.com 举报,一经查实,本站将立刻删除。如若转载,请注明出处:https://www.xiaomafuwu.com/311472.html