发布网友 发布时间:2022-03-31 18:32
共1个回答
热心网友 时间:2022-03-31 20:02
想要在WPS表格中把汉字转换成拼音或小写字母,只需要运用模块代码编辑功能就能轻松解决,具体操作方法如下:
步骤1、打开要转换成拼音的excel表格,按“Alt+F11”组合键,进入Visual Basic编辑状态。也就是看到的这个灰色的编辑界面。
步骤2、执行“插入→模块”命令,插入一个新模块。再双击插入的模块,进入模块代码编辑状态。
步骤3、看到如下界面。
步骤4、把下面的所有内容复制,粘贴到步骤4中的空白处。
Function pinyin(p As String) As String
i = Asc(p)
Select Case i
Case -20319 To -20318: pinyin = "a "
Case -20317 To -20305: pinyin = "ai "
Case -20304 To -20296: pinyin = "an "
Case -20295 To -20293: pinyin = "ang "
Case -20292 To -20284: pinyin = "ao "
Case -20283 To -20266: pinyin = "ba "
Case -20265 To -20258: pinyin = " "
Case -20257 To -20243: pinyin = "ban "
Case -20242 To -20231: pinyin = "bang "
Case -20230 To -20052: pinyin = "bao "
Case -20051 To -20037: pinyin = "bei "
Case -20036 To -20033: pinyin = "ben "
Case -20032 To -20027: pinyin = "beng "
Case -20026 To -20003: pinyin = "bi "
Case -20002 To -19991: pinyin = "bian "
Case -19990 To -19987: pinyin = "biao "
Case -19986 To -19983: pinyin = "bie "
Case -19982 To -19977: pinyin = "bin "
Case -19976 To -19806: pinyin = "bing "
Case -19805 To -19785: pinyin = "bo "
Case -19784 To -19776: pinyin = "bu "
Case -19775 To -19775: pinyin = "ca "
Case -17721 To -17704: pinyin = "he "
Case -17703 To -17702: pinyin = "hei "
Case -17701 To -17698: pinyin = "hen "
Case -17697 To -17693: pinyin = "heng "
Case -17692 To -17684: pinyin = "hong "
Case -17683 To -17677: pinyin = "hou "
Case -17676 To -17497: pinyin = "hu "
步骤5、按下ALT+Q关闭Visual Basic编辑窗口,返回Excel编辑状态。
步骤6、选中转换后的拼音需要放在哪个列,例如要把B列的第2行的内容转换成拼音,放在D列的第2个单元格,输入公式:=getpy(B2),这里的B2,是指源头单元格的坐标。
步骤7、如果要去除拼音之间的空格。去掉空格的拼音放在E列,如果这个未去掉空格的数据原来在D2单元格,去掉空格之后的拼音放在E2单元格,则在E2单元格输: =SUBSTITUTE(D2," ","")。