Excel 请问如何提取中文拼音第一个字母

2024-11-28 20:37:32
推荐回答(3个)
回答(1):

假设A列为汉字,提取的拼音第一个字母放在B列,以Excel2010版为例,操作如下:
1、单击菜单栏的“开发工具”,”Visual Basic“编辑器,Visual Basic编辑器
2、执行“插入→模块”命令,在模块代码编辑区输入下列代码:
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

3、代码输入完成后,关闭Visual Basic编辑窗口,返回Excel工作表;

4、在B1单元格,输入公式:=getpy(A1)。

回答(2):

如A列是汉字,从A1开始,则B1中的公式为:
=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"})
下拉填充

回答(3):

发表看下