excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

经验直达:

  • excel怎么把汉字转换成拼音
  • excel汉字转化为拼音公式

一、excel怎么把汉字转换成拼音


Excel中可以利用自定义函数来实现将汉字转换成拼音 。
所用工具:Office2007
举例说明如下:
1.将A列数据转换成拼音:
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

2.alt F11插入模块,在模块中输入如下代码,代码很多(由于篇幅限制,无法将全部代码发上来,可以搜索汉字ASC码来获?。砗芗虻?,利用每个汉字的ASC码来得到这个汉字的拼音,然后依次提取单元格中的每一个汉字,分别获得其拼音 。
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 = "bai "
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 -11055 To -11053: pinyin = "za "

Case -11052 To -11046: pinyin = "zai "
Case -11045 To -11042: pinyin = "zan "
Case -11041 To -11039: pinyin = "zang "
Case -11038 To -11025: pinyin = "zao "
Case -11024 To -11021: pinyin = "ze "
Case -11020 To -11020: pinyin = "zei "
Case -11019 To -11019: pinyin = "zen "
Case -11018 To -11015: pinyin = "zeng "
Case -11014 To -10839: pinyin = "zha "
Case -10838 To -10833: pinyin = "zhai "
Case -10832 To -10816: pinyin = "zhan "
Case -10815 To -10801: pinyin = "zhang "
Case -10800 To -10791: pinyin = "zhao "
Case -10790 To -10781: pinyin = "zhe "
Case -10780 To -10765: pinyin = "zhen "
Case -10764 To -10588: pinyin = "zheng "
Case -10587 To -10545: pinyin = "zhi "
Case -10544 To -10534: pinyin = "zhong "
Case -10533 To -10520: pinyin = "zhou "
Case -10519 To -10332: pinyin = "zhu "
Case -10331 To -10330: pinyin = "zhua "
Case -10329 To -10329: pinyin = "zhuai "
Case -10328 To -10323: pinyin = "zhuan "
Case -10322 To -10316: pinyin = "zhuang "
Case -10315 To -10310: pinyin = "zhui "
Case -10309 To -10308: pinyin = "zhun "
Case -10307 To -10297: pinyin = "zhuo "
Case -10296 To -10282: pinyin = "zi "
Case -10281 To -10275: pinyin = "zong "
Case -10274 To -10271: pinyin = "zou "
Case -10270 To -10263: pinyin = "zu "
Case -10262 To -10261: pinyin = "zuan "
Case -10260 To -10257: pinyin = "zui "
Case -10256 To -10255: pinyin = "zun "
Case -10254 To -10254: pinyin = "zuo "
Case Else: pinyin = p
End Select
End Function
Function py(str)
For i = 1 To Len(str)
py = py & pinyin(Mid(str, i, 1))
Next i
End Function


excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

3.这样,返回Excel利用自定义的py函数即可:
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

4.下拉填充,就可以得到全部汉字的拼音:
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音



二、excel汉字转化为拼音公式


汉字转化为拼音的公式:“=getpy(目标单元格)” 。
工具/原料:
联想Y7000P
Windows10
Excel 2007
1、首先用office Excel 2007打开文档 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

2、然后鼠标标定在D2单元格,输入公式“=getpy(C2)”,按回车键确认 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

3、我们就看到姓名一栏汉语拼音就自动出现了 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

4、选中D2单元格,鼠标放在单元格右下角 , 当出现“+”后,向下拖动鼠标 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

5、这样,姓名一栏所有的汉字都以拼音形式显示了 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

6、如果我们需要将拼音的首字母变成大写的话,可以将鼠标标定在E2单元格中,然后输入公式“=PROPER(D2)” , 按回车确认 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

7、这样,我们需要的拼音的首字母就变成大写的了 。
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音

8、然后重复步骤将鼠标放在单元格右下角,当出现“+”后 , 向下拖动鼠标 , 就完成了 。
【excel汉字转化为拼音公式 excel怎么把汉字转换成拼音】
excel汉字转化为拼音公式 excel怎么把汉字转换成拼音


相关经验推荐