转自:http://jingyan.baidu.com/article/63acb44adca44461fcc17e85.html
转自:http://jingyan.baidu.com/article/f79b7cb3a577689144023ef0.html
Sub xx()
For i = To [A65536].End().Row
Cells(i, ).Value = getpy(Cells(i, ).Value)
Next i End Sub Function pinyin(p As String) As String i = Asc(p) Select Case i Case - To -: pinyin = "A" Case - To -: pinyin = "B" Case - To -: pinyin = "C" Case - To -: pinyin = "D" Case - To -: pinyin = "E" Case - To -: pinyin = "F" Case - To -: pinyin = "G" Case - To -: pinyin = "H" Case - To -: pinyin = "J" Case - To -: pinyin = "K" Case - To -: pinyin = "L" Case - To -: pinyin = "M" Case - To -: pinyin = "N" Case - To -: pinyin = "O" Case - To -: pinyin = "P" Case - To -: pinyin = "Q" Case - To -: pinyin = "R" Case - To -: pinyin = "S" Case - To -: pinyin = "T" Case - To -: pinyin = "W" Case - To -: pinyin = "X" Case - To -: pinyin = "Y" Case - To -: pinyin = "Z" Case Else: pinyin = p End Select End Function Function getpy(str) As String
Dim result As String For i = To Len(str) result = result & pinyin(Mid(str, i, )) Next i getpy = result
End Function