码迷,mamicode.com
首页 > 其他好文 > 详细

[转]Excel 取汉字拼音首位

时间:2016-05-26 14:20:59      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:

转自:http://jingyan.baidu.com/article/63acb44adca44461fcc17e85.html
转自:http://jingyan.baidu.com/article/f79b7cb3a577689144023ef0.html
Sub xx()
  For i = 2 To [A65536].End(3).Row
    Cells(i, 2).Value = getpy(Cells(i, 1).Value)
  Next i

End Sub

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) As String
 Dim result As String
 
For i = 1 To Len(str)
 
result = result & pinyin(Mid(str, i, 1))
 
Next i
 
 getpy = result
End Function

 

[转]Excel 取汉字拼音首位

标签:

原文地址:http://www.cnblogs.com/z5337/p/5530881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!