excel 如何提取汉字首字母
时间:2022-06-21 09:25:38
答:如果用函数公式来做,需要汉字和拼音的对照表才行。这个问题,有大神推荐使用自定义函数,并且编写一段VBA代码来搞定。
操作步骤:打开VBE编辑器,插入模块,输入以下代码,返回工作表,B1单元格输入公式:=getpy(A1),下拉复制。
记得把文件格式存为XLSM,也就是启用宏的工作簿,否则有自定义函数的文件打开的时候会出现#NAME错误。
代码如下:
Functionpinyin(pAsString)AsString
i=Asc(p)
SelectCasei
Case-20319To-20284:pinyin="A"
Case-20283To-19776:pinyin="B"
Case-19775To-19219:pinyin="C"
Case-19218To-18711:pinyin="D"
Case-18710To-18527:pinyin="E"
Case-18526To-18240:pinyin="F"
Case-18239To-17923:pinyin="G"
Case-17922To-17418:pinyin="H"
Case-17417To-16475:pinyin="J"
Case-16474To-16213:pinyin="K"
Case-16212To-15641:pinyin="L"
Case-15640To-15166:pinyin="M"
Case-15165To-14923:pinyin="N"
Case-14922To-14915:pinyin="O"
Case-14914To-14631:pinyin="P"
Case-14630To-14150:pinyin="Q"
Case-14149To-14091:pinyin="R"
Case-14090To-13319:pinyin="S"
Case-13318To-12839:pinyin="T"
Case-12838To-12557:pinyin="W"
Case-12556To-11848:pinyin="X"
Case-11847To-11056:pinyin="Y"
Case-11055To-2050:pinyin="Z"
CaseElse:pinyin=p
EndSelect
EndFunction
Functiongetpy(str)
Fori=1ToLen(str)
getpy=getpy&pinyin(Mid(str,i,1))
Nexti
EndFunction
excel 如何提取汉字首字母的下载地址:
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
excel表格怎么查找重复项内容
wps文字中页码怎么修改
![](https://img.aspxhome.com/file/2023/6/a163666_0s.jpg)
word2007多个图形怎么组合成一个图形?
![](https://img.aspxhome.com/file/2023/6/22876_0s.jpg)
EXCEL表格的自定义状态栏滚动选项怎么关闭
![](https://img.aspxhome.com/file/2023/4/36784_0s.jpg)
excel表格内容换行的方法
Excel中COUNTIF函数有什么使用技巧
一招帮你解决WORD的NOT RESPONDING
![](https://img.aspxhome.com/file/2023/0/24930_0s.jpg)
Word2016页面设置在哪?Word2016设置页面方法
![](https://img.aspxhome.com/file/2023/7/22857_0s.jpg)
Win10专业版怎么让电脑不休眠?Win10专业版让电脑不休眠的方法
![](https://img.aspxhome.com/file/2023/5/49635_0s.png)
excel2013表格中怎么制作项目跟踪器?
![](https://img.aspxhome.com/file/2023/7/40177_0s.jpg )
Excel中VLOOKUP函数制作查询系统的使用方法
Excel如何将图片变为透明的 excel删除背景变透彻操作教程
怎么让Excel表格自动调整字号
![](https://img.aspxhome.com/file/2023/2/37232_0s.jpg)
excel监视窗口工具怎么使用呢?
![](https://img.aspxhome.com/file/2023/0/40700_0s.jpg)
excel怎么删除在网上复制下来的图片?
![](https://img.aspxhome.com/file/2023/4/41584_0s.jpg)
Win10系统禁用光驱的方法
![](https://img.aspxhome.com/file/2023/7/46947_0s.png)
Excel表格中怎么制作温度计图表?
![](https://img.aspxhome.com/file/2023/7/40467_0s.png)
如何用excel制作考勤表的方法
如何在word文档中插入用户保存的图片
![](https://img.aspxhome.com/file/2023/6/32996_0s.jpg)
你所不知道的那些 word 隐藏功能
![](https://img.aspxhome.com/file/2023/3/32763_0s.jpg)