比较简短的拼音首字母自定义函数

Function pinyin(ByVal r As Range) As String
Const hanzi = "啊芭擦搭蛾发噶哈击喀垃妈拿哦啪期然撒塌挖昔压匝ABCDEFGHJKLMNOPQRSTWXYZZ"
Dim i As Long, j As Byte, temp As String
For i = 1 To Len(r.Text)
For j = 1 To 24
If Asc(Mid(r.Text, i, 1)) >= Asc(Mid(hanzi, j, 1)) Then temp = Mid(hanzi, 23 + j, 1)
Next
pinyin = pinyin & temp
Next
End Function

用法:b1输入公式 =pinyin(a1)

你可能感兴趣的:(J#)