excel怎么把汉字转换成拼音

excel怎么把汉字转换成拼音,第1张

1、首先在自己电脑上,打开Excel一份表格。

2、在打开的表格D1单元格上,输入转拼音汉字,然后在D2单元格里输入=getpy(A2)公式。因为姓名在A列上,所以需要引用单元格选择A2。

3、输入完公式选中好引用名字的单元格之后,按下确定键在D2单元格就可以看到姓名已经转换成拼音了。

4、然后选中D2单元格的拼音名字,向下拉对下列单元格进行转换即可。

步骤:

第一步、启动Excel 2003(其它版本请仿照 *** 作),打开相应的工作表;

第二步、执行“工具→宏→Visual Basic编辑器”命令(或者直接按“Alt+F11”组合键),进入Visual Basic编辑状态;

第三步、执行“插入→模块”命令,插入一个新模块。再双击插入的模块,进入模块代码编辑状态;

第四步、将代码输入其中;

Function pinyin(p As String) As String

i = Asc(p)

Select Case i

Case -20319 To -20284: pinyin = "A"

Case -20283 To -19776: 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 -17418: 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

第五步、代码输入完成后,关闭Visual Basic编辑窗口,返回Excel编辑状态;

第六步、自定义函数就可以用了,如:选中A2单元格,输入公式:=getpy(A2)。

有时候在记录一些文字时需要用到拼音,如果自己用手一个个输入会显得非常麻烦,那么该如何将汉字直接转换成拼音呢,这里和大家简单介绍一下,供大家参考,希望对大家能有所帮助。

首先打开excel表格,在里面输入一些自己要拼音的汉字,有些人就是想直接在表格中输入拼音,然后点击列,点击鼠标右键,然后选择复制,这时候就复制好了,然后打开word文档,将复制内容黏贴进来即可。

接着点击开始处,然后找到拼音指南,如图所示是一个文字,还有拼音的符号,直接点击这个即可。

然后设置好拼音的字体大小即可,接着点击确定,这时候就能在word文档中看到文字都加上拼音了,非常快速。

将带有拼音的文字一个个复制到excel中来就行了,这样在表格中也能很快得到拼音,最后将文字删除掉就可以了。

你可以在Word里面输入需要的内容,标注拼音

标注拼音后在excel里进行粘贴,(双击单元格粘贴会显示成前面汉字后面拼音,直接鼠标点击单元格粘贴拼音在汉字上面)

注意excel表格里也有拼音,是标注拼音需要自己输入的。

1、打开要转换成拼音的excel表格

2、按“Alt+F11”组合键,进入Visual Basic编辑状态。也就是看到的这个灰色的编辑界面

3、执行“插入→模块”命令,插入一个新模块。再双击插入的模块,进入模块代码编辑状态;

4、看到如下界面

5、把下面的所有内容复制,粘贴到步骤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 = "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 -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 getpy(str)

For i = 1 To Len(str)

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

Next i

End Function

6、按下ALT+Q关闭Visual Basic编辑窗口,返回Excel编辑状态

7、选中转换后的拼音需要放在哪个列,例如要把B列的第2行的内容转换成拼音,放在D列的第2个单元格,输入公式:=getpy(B2),这里的B2,是指源头单元格的坐标

8、如果要去除拼音之间的空格。去掉空格的拼音放在E列,如果这个未去掉空格的数据原来在D2单元格,去掉空格之后的拼音放在E2单元格,则在E2单元格输入:

=SUBSTITUTE(D2," ","")

软件版本:Office2013方法如下:1Alt+F11,打开VBA编辑界面,插入模块,在模块中输入如下代码:Function pinyin(p As String) As Stringi = Asc(p)Select Case iCase -20319 To -20318: pinyin = "a "……(受字数限制,中间部分省略)Case -10254 To -10254: pinyin = "zuo "Case Else: pinyin = pEnd SelectEnd FunctionFunction py(x)For i = 1 To Len(x)py = py & pinyin(Mid(x, i, 1))Next iEnd Function2回到Excel中,输入公式如下:=py(A1)3下拉填充得到结果如下:

分两步

1、取得拼音

得用到VBA

打开Excel->工具->宏->Viaual Basic编辑器

在d出来的窗口中对着VBAproject点右键->插入->模块

下面会出现一个名为"模块1",点击

在右边的空白栏中粘贴以下内容:

''''''''''''''''''''''''''''''

Function getpychar(char)

tmp = 65536 + Asc(char)

If (tmp >= 45217 And tmp <= 45252) Then

getpychar = "A"

ElseIf (tmp >= 45253 And tmp <= 45760) Then

getpychar = "B"

ElseIf (tmp >= 45761 And tmp <= 46317) Then

getpychar = "C"

ElseIf (tmp >= 46318 And tmp <= 46825) Then

getpychar = "D"

ElseIf (tmp >= 46826 And tmp <= 47009) Then

getpychar = "E"

ElseIf (tmp >= 47010 And tmp <= 47296) Then

getpychar = "F"

ElseIf (tmp >= 47297 And tmp <= 47613) Then

getpychar = "G"

ElseIf (tmp >= 47614 And tmp <= 48118) Then

getpychar = "H"

ElseIf (tmp >= 48119 And tmp <= 49061) Then

getpychar = "J"

ElseIf (tmp >= 49062 And tmp <= 49323) Then

getpychar = "K"

ElseIf (tmp >= 49324 And tmp <= 49895) Then

getpychar = "L"

ElseIf (tmp >= 49896 And tmp <= 50370) Then

getpychar = "M"

ElseIf (tmp >= 50371 And tmp <= 50613) Then

getpychar = "N"

ElseIf (tmp >= 50614 And tmp <= 50621) Then

getpychar = "O"

ElseIf (tmp >= 50622 And tmp <= 50905) Then

getpychar = "P"

ElseIf (tmp >= 50906 And tmp <= 51386) Then

getpychar = "Q"

ElseIf (tmp >= 51387 And tmp <= 51445) Then

getpychar = "R"

ElseIf (tmp >= 51446 And tmp <= 52217) Then

getpychar = "S"

ElseIf (tmp >= 52218 And tmp <= 52697) Then

getpychar = "T"

ElseIf (tmp >= 52698 And tmp <= 52979) Then

getpychar = "W"

ElseIf (tmp >= 52980 And tmp <= 53640) Then

getpychar = "X"

ElseIf (tmp >= 53689 And tmp <= 54480) Then

getpychar = "Y"

ElseIf (tmp >= 54481 And tmp <= 62289) Then

getpychar = "Z"

Else '如果不是中文,则不处理

getpychar = char

End If

End Function

Function getpy(str)

For i = 1 To Len(str)

getpy = getpy & getpychar(Mid(str, i, 1))

Next i

End Function

按ALT+F11回到EXCEL

2、如果你的表如下

A B C D

1 姓名 出生年月 工作时间

2 刘德华 1965 1982

在D2单元格输入公式

=getpy(A2)&right(B2,2)&right(C2,2)

OK了

以上就是关于excel怎么把汉字转换成拼音全部的内容,包括:excel怎么把汉字转换成拼音、excel中如何实现提取汉字的拼音首字母、Excel如何把汉字转换成拼音等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9713018.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-01
下一篇 2023-05-01

发表评论

登录后才能评论

评论列表(0条)

保存