资源描述:
《EXCEL中直接把中文转换成拼音全拼》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1.第一种方法:打开Excel->工具->宏->ViaualBasic编辑器在弹出来的窗口中对着VBAproject点右键->插入->模块下面会出现一个名为"模块1",点击在右边的空白栏中粘贴以下内容: Functiongetpychar(char)tmp=65536+Asc(char)If(tmp>=45217Andtmp<=45252)Thengetpychar="A"ElseIf(tmp>=45253Andtmp<=45760)Thengetpychar="B"ElseIf(tmp>=45761Andtmp<=46317)Thengetpychar="C"ElseIf(tmp
2、>=46318Andtmp<=46825)Thengetpychar="D"ElseIf(tmp>=46826Andtmp<=47009)Thengetpychar="E"ElseIf(tmp>=47010Andtmp<=47296)Thengetpychar="F"ElseIf(tmp>=47297Andtmp<=47613)Thengetpychar="G"ElseIf(tmp>=47614Andtmp<=48118)Thengetpychar="H"ElseIf(tmp>=48119Andtmp<=49061)Thengetpychar="J"ElseIf(tmp>=4906
3、2Andtmp<=49323)Thengetpychar="K"ElseIf(tmp>=49324Andtmp<=49895)Thengetpychar="L"ElseIf(tmp>=49896Andtmp<=50370)Thengetpychar="M"ElseIf(tmp>=50371Andtmp<=50613)Thengetpychar="N"ElseIf(tmp>=50614Andtmp<=50621)Thengetpychar="O"ElseIf(tmp>=50622Andtmp<=50905)Thengetpychar="P"ElseIf(tmp>=50906Andtm
4、p<=51386)Thengetpychar="Q"ElseIf(tmp>=51387Andtmp<=51445)Thengetpychar="R"ElseIf(tmp>=51446Andtmp<=52217)Thengetpychar="S"ElseIf(tmp>=52218Andtmp<=52697)Thengetpychar="T"ElseIf(tmp>=52698Andtmp<=52979)Thengetpychar="W"ElseIf(tmp>=52980Andtmp<=53640)Thengetpychar="X"ElseIf(tmp>=53689Andtmp<=544
5、80)Thengetpychar="Y"ElseIf(tmp>=54481Andtmp<=62289)Thengetpychar="Z"Else'如果不是中文,则不处理getpychar=charEndIfEndFunctionFunctiongetpy(str)Fori=1ToLen(str)getpy=getpy&getpychar(Mid(str,i,1))NextiEndFunction 现在转换函数已编写完成!关掉此编缉的窗口。要在Excel中使用,方法如下:A1 A2中国 =getpy(A1) 2.第二种方法更简单些,但只能转单个字:=IF(LE
6、N(A1)>0,LOOKUP(CODE(A1),45217+{0,36,544,1101,1609,1793,2080,2560,2902,3845,4107,4679,5154,5397,5405,5689,6170,6229,7001,7481,7763,8472,9264},{"A","B","C","D","E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T","W","X","Y","Z"}),"")