昨晚休息的时候,赵 sir发来消息,突然有急事,需要把大批量的单元格汉字名字转换为拼音。迅粗略搜了下百度,发现office Excel 是很方便的,而赵 sir电脑装的是wps。百度了下,发现关于WPS,Excel单元格,汉字转拼音的方法寥寥无几,当然office跟wps实现此功能原理上都是一样的,差别在于有些人可能下载的wps无vba,安装又很难找到对应的版本。故有此文。废话不多说,直接看。

 必须带有宏功能的WPS。(具体软件看附件,已全部打包,含视频)。    【WPS单元格】汉字转拼音的方法-LMLPHP

  官网可看到就是该版本。软件安装过程就不说了,傻瓜式下一步。软件打开时需要激活码:9DP6T-9AGWG-KWV33-9MPC8-JDCVF

    激活后关闭软件,通过双击桌面图标打开wps,(通过桌面打开是防止部分用户也装了office Excel,导致功能无法实现。本人就是这样,浪费了好一会时间)

     【WPS单元格】汉字转拼音的方法-LMLPHP

【WPS单元格】汉字转拼音的方法-LMLPHP

   该界面下,使用Alt+F11打开VB代码编辑窗口,

    【WPS单元格】汉字转拼音的方法-LMLPHP

点击插入-模块-打开vb编辑窗口。如下图

【WPS单元格】汉字转拼音的方法-LMLPHP

以下代码复制到窗体中

Function pinyin(p As String) As String

i = Asc(p)

Select Case i

Case - To -: pinyin = "a "

Case - To -: pinyin = "ai "

Case - To -: pinyin = "an "

Case - To -: pinyin = "ang "

Case - To -: pinyin = "ao "

Case - To -: pinyin = "ba "

Case - To -: pinyin = "bai "

Case - To -: pinyin = "ban "

Case - To -: pinyin = "bang "

Case - To -: pinyin = "bao "

Case - To -: pinyin = "bei "

Case - To -: pinyin = "ben "

Case - To -: pinyin = "beng "

Case - To -: pinyin = "bi "

Case - To -: pinyin = "bian "

Case - To -: pinyin = "biao "

Case - To -: pinyin = "bie "

Case - To -: pinyin = "bin "

Case - To -: pinyin = "bing "

Case - To -: pinyin = "bo "

Case - To -: pinyin = "bu "

Case - To -: pinyin = "ca "

Case - To -: pinyin = "cai "

Case - To -: pinyin = "can "

Case - To -: pinyin = "cang "

Case - To -: pinyin = "cao "

Case - To -: pinyin = "ce "

Case - To -: pinyin = "ceng "

Case - To -: pinyin = "cha "

Case - To -: pinyin = "chai "

Case - To -: pinyin = "chan "

Case - To -: pinyin = "chang "

Case - To -: pinyin = "chao "

Case - To -: pinyin = "che "

Case - To -: pinyin = "chen "

Case - To -: pinyin = "cheng "

Case - To -: pinyin = "chi "

Case - To -: pinyin = "chong "

Case - To -: pinyin = "chou "

Case - To -: pinyin = "chu "

Case - To -: pinyin = "chuai "

Case - To -: pinyin = "chuan "

Case - To -: pinyin = "chuang "

Case - To -: pinyin = "chui "

Case - To -: pinyin = "chun "

Case - To -: pinyin = "chuo "

Case - To -: pinyin = "ci "

Case - To -: pinyin = "cong "

Case - To -: pinyin = "cou "

Case - To -: pinyin = "cu "

Case - To -: pinyin = "cuan "

Case - To -: pinyin = "cui "

Case - To -: pinyin = "cun "

Case - To -: pinyin = "cuo "

Case - To -: pinyin = "da "

Case - To -: pinyin = "dai "

Case - To -: pinyin = "dan "

Case - To -: pinyin = "dang "

Case - To -: pinyin = "dao "

Case - To -: pinyin = "de "

Case - To -: pinyin = "deng "

Case - To -: pinyin = "di "

Case - To -: pinyin = "dian "

Case - To -: pinyin = "diao "

Case - To -: pinyin = "die "

Case - To -: pinyin = "ding "

Case - To -: pinyin = "diu "

Case - To -: pinyin = "dong "

Case - To -: pinyin = "fa "

Case - To -: pinyin = "fan "

Case - To -: pinyin = "fang "

Case - To -: pinyin = "fei "

Case - To -: pinyin = "fen "

Case - To -: pinyin = "feng "

Case - To -: pinyin = "fo "

Case - To -: pinyin = "fou "

Case - To -: pinyin = "fu "

Case - To -: pinyin = "ga "

Case - To -: pinyin = "gai "

Case - To -: pinyin = "gan "

Case - To -: pinyin = "gang "

Case - To -: pinyin = "gao "

Case - To -: pinyin = "ge "

Case - To -: pinyin = "gei "

Case - To -: pinyin = "gen "

Case - To -: pinyin = "geng "

Case - To -: pinyin = "gong "

Case - To -: pinyin = "gou "

Case - To -: pinyin = "gu "

Case - To -: pinyin = "gua "

Case - To -: pinyin = "guai "

Case - To -: pinyin = "guan "

Case - To -: pinyin = "guang "

Case - To -: pinyin = "gui "

Case - To -: pinyin = "gun "

Case - To -: pinyin = "guo "

Case - To -: pinyin = "ha "

Case - To -: pinyin = "hai "

Case - To -: pinyin = "han "

Case - To -: pinyin = "hang "

Case - To -: pinyin = "hao "

Case - To -: pinyin = "he "

Case - To -: pinyin = "hei "

Case - To -: pinyin = "hen "

Case - To -: pinyin = "heng "

Case - To -: pinyin = "hong "

Case - To -: pinyin = "hou "

Case - To -: pinyin = "hu "

Case - To -: pinyin = "hua "

Case - To -: pinyin = "huai "

Case - To -: pinyin = "huan "

Case - To -: pinyin = "huang "

Case - To -: pinyin = "hui "

Case - To -: pinyin = "hun "

Case - To -: pinyin = "huo "

Case - To -: pinyin = "ji "

Case - To -: pinyin = "jia "

Case - To -: pinyin = "jian "

Case - To -: pinyin = "jiang "

Case - To -: pinyin = "jiao "

Case - To -: pinyin = "jie "

Case - To -: pinyin = "jin "

Case - To -: pinyin = "jing "

Case - To -: pinyin = "jiong "

Case - To -: pinyin = "jiu "

Case - To -: pinyin = "ju "

Case - To -: pinyin = "juan "

Case - To -: pinyin = "jue "

Case - To -: pinyin = "jun "

Case - To -: pinyin = "ka "

Case - To -: pinyin = "kai "

Case - To -: pinyin = "kan "

Case - To -: pinyin = "kang "

Case - To -: pinyin = "kao "

Case - To -: pinyin = "ke "

Case - To -: pinyin = "ken "

Case - To -: pinyin = "keng "

Case - To -: pinyin = "kong "

Case - To -: pinyin = "kou "

Case - To -: pinyin = "ku "

Case - To -: pinyin = "kua "

Case - To -: pinyin = "kuai "

Case - To -: pinyin = "kuan "

Case - To -: pinyin = "kuang "

Case - To -: pinyin = "kui "

Case - To -: pinyin = "kun "

Case - To -: pinyin = "kuo "

Case - To -: pinyin = "la "

Case - To -: pinyin = "lai "

Case - To -: pinyin = "lan "

Case - To -: pinyin = "lang "

Case - To -: pinyin = "lao "

Case - To -: pinyin = "le "

Case - To -: pinyin = "lei "

Case - To -: pinyin = "leng "

Case - To -: pinyin = "li "

Case - To -: pinyin = "lia "

Case - To -: pinyin = "lian "

Case - To -: pinyin = "liang "

Case - To -: pinyin = "liao "

Case - To -: pinyin = "lie "

Case - To -: pinyin = "lin "

Case - To -: pinyin = "ling "

Case - To -: pinyin = "liu "

Case - To -: pinyin = "long "

Case - To -: pinyin = "lou "

Case - To -: pinyin = "lu "

Case - To -: pinyin = "lv "

Case - To -: pinyin = "luan "

Case - To -: pinyin = "lue "

Case - To -: pinyin = "lun "

Case - To -: pinyin = "luo "

Case - To -: pinyin = "ma "

Case - To -: pinyin = "mai "

Case - To -: pinyin = "man "

Case - To -: pinyin = "mang "

Case - To -: pinyin = "mao "

Case - To -: pinyin = "me "

Case - To -: pinyin = "mei "

Case - To -: pinyin = "men "

Case - To -: pinyin = "meng "

Case - To -: pinyin = "mi "

Case - To -: pinyin = "mian "

Case - To -: pinyin = "miao "

Case - To -: pinyin = "mie "

Case - To -: pinyin = "min "

Case - To -: pinyin = "ming "

Case - To -: pinyin = "miu "

Case - To -: pinyin = "mo "

Case - To -: pinyin = "mou "

Case - To -: pinyin = "mu "

Case - To -: pinyin = "na "

Case - To -: pinyin = "nai "

Case - To -: pinyin = "nan "

Case - To -: pinyin = "nang "

Case - To -: pinyin = "nao "

Case - To -: pinyin = "ne "

Case - To -: pinyin = "nei "

Case - To -: pinyin = "nen "

Case - To -: pinyin = "neng "

Case - To -: pinyin = "ni "

Case - To -: pinyin = "nian "

Case - To -: pinyin = "niang "

Case - To -: pinyin = "niao "

Case - To -: pinyin = "nie "

Case - To -: pinyin = "nin "

Case - To -: pinyin = "ning "

Case - To -: pinyin = "niu "

Case - To -: pinyin = "nong "

Case - To -: pinyin = "nu "

Case - To -: pinyin = "nv "

Case - To -: pinyin = "nuan "

Case - To -: pinyin = "nue "

Case - To -: pinyin = "nuo "

Case - To -: pinyin = "o "

Case - To -: pinyin = "ou "

Case - To -: pinyin = "pa "

Case - To -: pinyin = "pai "

Case - To -: pinyin = "pan "

Case - To -: pinyin = "pang "

Case - To -: pinyin = "pao "

Case - To -: pinyin = "pei "

Case - To -: pinyin = "pen "

Case - To -: pinyin = "peng "

Case - To -: pinyin = "pi "

Case - To -: pinyin = "pian "

Case - To -: pinyin = "piao "

Case - To -: pinyin = "pie "

Case - To -: pinyin = "pin "

Case - To -: pinyin = "ping "

Case - To -: pinyin = "po "

Case - To -: pinyin = "pu "

Case - To -: pinyin = "qi "

Case - To -: pinyin = "qia "

Case - To -: pinyin = "qian "

Case - To -: pinyin = "qiang "

Case - To -: pinyin = "qiao "

Case - To -: pinyin = "qie "

Case - To -: pinyin = "qin "

Case - To -: pinyin = "qing "

Case - To -: pinyin = "qiong "

Case - To -: pinyin = "qiu "

Case - To -: pinyin = "qu "

Case - To -: pinyin = "quan "

Case - To -: pinyin = "que "

Case - To -: pinyin = "qun "

Case - To -: pinyin = "ran "

Case - To -: pinyin = "rang "

Case - To -: pinyin = "rao "

Case - To -: pinyin = "re "

Case - To -: pinyin = "ren "

Case - To -: pinyin = "reng "

Case - To -: pinyin = "ri "

Case - To -: pinyin = "rong "

Case - To -: pinyin = "rou "

Case - To -: pinyin = "ru "

Case - To -: pinyin = "ruan "

Case - To -: pinyin = "rui "

Case - To -: pinyin = "run "

Case - To -: pinyin = "ruo "

Case - To -: pinyin = "sa "

Case - To -: pinyin = "sai "

Case - To -: pinyin = "san "

Case - To -: pinyin = "sang "

Case - To -: pinyin = "sao "

Case - To -: pinyin = "se "

Case - To -: pinyin = "sen "

Case - To -: pinyin = "seng "

Case - To -: pinyin = "sha "

Case - To -: pinyin = "shai "

Case - To -: pinyin = "shan "

Case - To -: pinyin = "shang "

Case - To -: pinyin = "shao "

Case - To -: pinyin = "she "

Case - To -: pinyin = "shen "

Case - To -: pinyin = "sheng "

Case - To -: pinyin = "shi "

Case - To -: pinyin = "shou "

Case - To -: pinyin = "shu "

Case - To -: pinyin = "shua "

Case - To -: pinyin = "shuai "

Case - To -: pinyin = "shuan "

Case - To -: pinyin = "shuang "

Case - To -: pinyin = "shui "

Case - To -: pinyin = "shun "

Case - To -: pinyin = "shuo "

Case - To -: pinyin = "si "

Case - To -: pinyin = "song "

Case - To -: pinyin = "sou "

Case - To -: pinyin = "su "

Case - To -: pinyin = "suan "

Case - To -: pinyin = "sui "

Case - To -: pinyin = "sun "

Case - To -: pinyin = "suo "

Case - To -: pinyin = "ta "

Case - To -: pinyin = "tai "

Case - To -: pinyin = "tan "

Case - To -: pinyin = "tang "

Case - To -: pinyin = "tao "

Case - To -: pinyin = "te "

Case - To -: pinyin = "teng "

Case - To -: pinyin = "ti "

Case - To -: pinyin = "tian "

Case - To -: pinyin = "tiao "

Case - To -: pinyin = "tie "

Case - To -: pinyin = "ting "

Case - To -: pinyin = "tong "

Case - To -: pinyin = "tou "

Case - To -: pinyin = "tu "

Case - To -: pinyin = "tuan "

Case - To -: pinyin = "tui "

Case - To -: pinyin = "tun "

Case - To -: pinyin = "tuo "

Case - To -: pinyin = "wa "

Case - To -: pinyin = "wai "

Case - To -: pinyin = "wan "

Case - To -: pinyin = "wang "

Case - To -: pinyin = "wei "

Case - To -: pinyin = "wen "

Case - To -: pinyin = "weng "

Case - To -: pinyin = "wo "

Case - To -: pinyin = "wu "

Case - To -: pinyin = "xi "

Case - To -: pinyin = "xia "

Case - To -: pinyin = "xian "

Case - To -: pinyin = "xiang "

Case - To -: pinyin = "xiao "

Case - To -: pinyin = "xie "

Case - To -: pinyin = "xin "

Case - To -: pinyin = "xing "

Case - To -: pinyin = "xiong "

Case - To -: pinyin = "xiu "

Case - To -: pinyin = "xu "

Case - To -: pinyin = "xuan "

Case - To -: pinyin = "xue "

Case - To -: pinyin = "xun "

Case - To -: pinyin = "ya "

Case - To -: pinyin = "yan "

Case - To -: pinyin = "yang "

Case - To -: pinyin = "yao "

Case - To -: pinyin = "ye "

Case - To -: pinyin = "yi "

Case - To -: pinyin = "yin "

Case - To -: pinyin = "ying "

Case - To -: pinyin = "yo "

Case - To -: pinyin = "yong "

Case - To -: pinyin = "you "

Case - To -: pinyin = "yu "

Case - To -: pinyin = "yuan "

Case - To -: pinyin = "yue "

Case - To -: pinyin = "yun "

Case - To -: pinyin = "za "

Case - To -: pinyin = "zai "

Case - To -: pinyin = "zan "

Case - To -: pinyin = "zang "

Case - To -: pinyin = "zao "

Case - To -: pinyin = "ze "

Case - To -: pinyin = "zei "

Case - To -: pinyin = "zen "

Case - To -: pinyin = "zeng "

Case - To -: pinyin = "zha "

Case - To -: pinyin = "zhai "

Case - To -: pinyin = "zhan "

Case - To -: pinyin = "zhang "

Case - To -: pinyin = "zhao "

Case - To -: pinyin = "zhe "

Case - To -: pinyin = "zhen "

Case - To -: pinyin = "zheng "

Case - To -: pinyin = "zhi "

Case - To -: pinyin = "zhong "

Case - To -: pinyin = "zhou "

Case - To -: pinyin = "zhu "

Case - To -: pinyin = "zhua "

Case - To -: pinyin = "zhuai "

Case - To -: pinyin = "zhuan "

Case - To -: pinyin = "zhuang "

Case - To -: pinyin = "zhui "

Case - To -: pinyin = "zhun "

Case - To -: pinyin = "zhuo "

Case - To -: pinyin = "zi "

Case - To -: pinyin = "zong "

Case - To -: pinyin = "zou "

Case - To -: pinyin = "zu "

Case - To -: pinyin = "zuan "

Case - To -: pinyin = "zui "

Case - To -: pinyin = "zun "

Case - To -: pinyin = "zuo "

Case Else: pinyin = p

End Select

End Function

Function getpy(str)

For i =  To Len(str)

getpy = getpy & pinyin(Mid(str, i, ))

Next i

End Function

插入完成后,如下图,快捷键:Alt+Q,关闭VB窗口。即可开始使用公式。

【WPS单元格】汉字转拼音的方法-LMLPHP

  如图

【WPS单元格】汉字转拼音的方法-LMLPHP

    

【WPS单元格】汉字转拼音的方法-LMLPHP

注:可能会出现小部分汉字无法转成功,请检查,目前暂时先手动更改。这方面若有好的建议可以提出。

百度链接:https://pan.baidu.com/s/17cLqusSfTPEv8M9b2MGzlg 密码:kevk

05-16 01:47