我想在EXCEL中将一组姓名转换成拼音,并且姓和名要隔开的,可我不会VBA.怎么办????急
2个回答
展开全部
在EXECL中 ,按ALT+F11,插入---模块 复制下列代码 :
Function hztopy(hzpy As String) As String
Dim hzstring As String, pystring As String
Dim hzpysum As Integer, hzi As Integer, hzpyhex As Integer
hzstring = Trim(hzpy)
hzpysum = Len(Trim(hzstring))
pystring = ""
For hzi = 1 To hzpysum
hzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))
Select Case hzpyhex
Case &HB0A1 To &HB0C4: pystring = pystring + "A"
Case &HB0C5 To &HB2C0: pystring = pystring + "B"
Case &HB2C1 To &HB4ED: pystring = pystring + "C"
Case &HB4EE To &HB6E9: pystring = pystring + "D"
Case &HB6EA To &HB7A1: pystring = pystring + "E"
Case &HB7A2 To &HB8C0: pystring = pystring + "F"
Case &HB8C1 To &HB9FD: pystring = pystring + "G"
Case &HB9FE To &HBBF6: pystring = pystring + "H"
Case &HBBF7 To &HBFA5: pystring = pystring + "J"
Case &HBFA6 To &HC0AB: pystring = pystring + "K"
Case &HC0AC To &HC2E7: pystring = pystring + "L"
Case &HC2E8 To &HC4C2: pystring = pystring + "M"
Case &HC4C3 To &HC5B5: pystring = pystring + "N"
Case &HC5B6 To &HC5BD: pystring = pystring + "O"
Case &HC5BE To &HC6D9: pystring = pystring + "P"
Case &HC6DA To &HC8BA: pystring = pystring + "Q"
Case &HC8BB To &HC8F5: pystring = pystring + "R"
Case &HC8F6 To &HCBF9: pystring = pystring + "S"
Case &HCBFA To &HCDD9: pystring = pystring + "T"
Case &HEDC5: pystring = pystring + "T"
Case &HCDDA To &HCEF3: pystring = pystring + "W"
Case &HCEF4 To &HD1B8: pystring = pystring + "X"
Case &HD1B9 To &HD4D0: pystring = pystring + "Y"
Case &HD4D1 To &HD7F9: pystring = pystring + "Z"
Case Else
pystring = pystring + Mid(hzstring, hzi, 1)
End Select
Next
hztopy = pystring
End Function
比如在A1输入 中文 则在其他空白单元格输入 =hztopy(A1) 回车执行即可.
Function hztopy(hzpy As String) As String
Dim hzstring As String, pystring As String
Dim hzpysum As Integer, hzi As Integer, hzpyhex As Integer
hzstring = Trim(hzpy)
hzpysum = Len(Trim(hzstring))
pystring = ""
For hzi = 1 To hzpysum
hzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))
Select Case hzpyhex
Case &HB0A1 To &HB0C4: pystring = pystring + "A"
Case &HB0C5 To &HB2C0: pystring = pystring + "B"
Case &HB2C1 To &HB4ED: pystring = pystring + "C"
Case &HB4EE To &HB6E9: pystring = pystring + "D"
Case &HB6EA To &HB7A1: pystring = pystring + "E"
Case &HB7A2 To &HB8C0: pystring = pystring + "F"
Case &HB8C1 To &HB9FD: pystring = pystring + "G"
Case &HB9FE To &HBBF6: pystring = pystring + "H"
Case &HBBF7 To &HBFA5: pystring = pystring + "J"
Case &HBFA6 To &HC0AB: pystring = pystring + "K"
Case &HC0AC To &HC2E7: pystring = pystring + "L"
Case &HC2E8 To &HC4C2: pystring = pystring + "M"
Case &HC4C3 To &HC5B5: pystring = pystring + "N"
Case &HC5B6 To &HC5BD: pystring = pystring + "O"
Case &HC5BE To &HC6D9: pystring = pystring + "P"
Case &HC6DA To &HC8BA: pystring = pystring + "Q"
Case &HC8BB To &HC8F5: pystring = pystring + "R"
Case &HC8F6 To &HCBF9: pystring = pystring + "S"
Case &HCBFA To &HCDD9: pystring = pystring + "T"
Case &HEDC5: pystring = pystring + "T"
Case &HCDDA To &HCEF3: pystring = pystring + "W"
Case &HCEF4 To &HD1B8: pystring = pystring + "X"
Case &HD1B9 To &HD4D0: pystring = pystring + "Y"
Case &HD4D1 To &HD7F9: pystring = pystring + "Z"
Case Else
pystring = pystring + Mid(hzstring, hzi, 1)
End Select
Next
hztopy = pystring
End Function
比如在A1输入 中文 则在其他空白单元格输入 =hztopy(A1) 回车执行即可.
展开全部
比如在A1输入 中文 则在其他空白单元格输入 =hztopy(A1) 回车执行即可.
追问
试了,还是不行,
追答
所以只能以我自己做的来举例。这样做:第一步:如果名是两个字的(假设存放在D列),把两个字各放一列,公式=right(D1,1),具体位置依此类推。第二步:把A列(即姓这一列)贴到记事本里,这样出来的是文本,然后再把文本贴到WORD里,抹黑这些文本,然后格式-〉中文版式-〉拼音指南。看一看,是不是出现了拼音信息。第三步:还是抹黑上述文本,然后表格-〉转换-〉文字转化成表格,再把表格贴回到B列去,然后在C列中写公式=phonetic(b1),拼音信息就取出来了。第四步:将名的两列(假设是E、F)照以上处理,把拼音信息又另放两列(假设是G、H)。然后取首字母,公式=left(G1,1)。其他依此类推。取出的首字母又另放两列(假设是I、J)。第五步:合并I、J两列内容。公式=concatenate(I1,J1)。其他依此类推。合并后的内容在K列。第六步:把ACDK四列选择性粘贴到空白表页或者空白单元格里就完成了。 另:1、你需要有微软拼音输入法2.0以上才行。 2、取出的拼音信息中会有1234这几个数字,那是表示声调的。你只需在Excel中使用替换,把这几个数字替换成空就可以了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询