Excel如何提取汉语拼音的缩写?
发布网友
发布时间:2022-04-30 00:30
我来回答
共3个回答
热心网友
时间:2022-06-27 05:48
可以编写一个自定义函数解决
Option Compare Text
Function JPY(cel As Range)
For i = 1 To Len(cel.Value)
ss = Mid(cel.Value, i, 1)
k = 1
Do Until Mid("阿芭才搭蛾发噶哈击击咔垃妈拿哦啪期然撒塌挖挖挖西压匝咗", k, 1) > ss
k = k + 1
Loop
py = py & Chr(95 + k)
Next
JPY = py
End Function
如D20为“半自动帽子”,则自定义函数为 =JPY(D20), 结果为 bzdmz
热心网友
时间:2022-06-27 05:48
◎ 宏可以做到。
◎ 本宏的使用:打开EXCEL,设置宏安全性为中或低(“工具”->“宏”->“安全性”,在打开的对话框中,选择“中”或“低”。建议选“中”)。 按【ALT】+【F11】,在左边“工程”中点右键,“插入”→“模块”,贴入代码。
◎ 代码如下:
Public Function HZ2PY(Tstr As String, Optional onlyFirst As Boolean) As String
On Error GoTo Err
If onlyFirst Then Tstr = Left(Tstr, 1)
Dim intTstrLong As Integer
Dim strPY As String
Dim i As Long, p As Integer
For intTstrLong = 1 To Len(Tstr)
i = Asc(Mid(Tstr, intTstrLong, 1))
If i <= Asc("啊") Or i >= Asc("座") Then
strPY = strPY & Mid(Tstr, intTstrLong, 1)
Else
If i >= Asc("啊") And i < Asc("芭") Then p = 65
If i >= Asc("芭") And i < Asc("擦") Then p = 66
If i >= Asc("擦") And i < Asc("搭") Then p = 67
If i >= Asc("搭") And i < Asc("蛾") Then p = 68
If i >= Asc("蛾") And i < Asc("发") Then p = 69
If i >= Asc("发") And i < Asc("噶") Then p = 70
If i >= Asc("噶") And i < Asc("哈") Then p = 71
If i >= Asc("哈") And i < Asc("击") Then p = 72
If i >= Asc("击") And i < Asc("喀") Then p = 74
If i >= Asc("喀") And i < Asc("垃") Then p = 75
If i >= Asc("垃") And i < Asc("妈") Then p = 76
If i >= Asc("妈") And i < Asc("拿") Then p = 77
If i >= Asc("拿") And i < Asc("哦") Then p = 78
If i >= Asc("哦") And i < Asc("啪") Then p = 79
If i >= Asc("啪") And i < Asc("欺") Then p = 80
If i >= Asc("欺") And i < Asc("然") Then p = 81
If i >= Asc("然") And i < Asc("撒") Then p = 82
If i >= Asc("撒") And i < Asc("塌") Then p = 83
If i >= Asc("塌") And i < Asc("挖") Then p = 84
If i >= Asc("挖") And i < Asc("昔") Then p = 87
太长贴不下,下面接着来
热心网友
时间:2022-06-27 05:48
嘻嘻..好难啊!我天天用还不知道有这功能..