Excel 取出 文字 首字母

2025-03-28 20:56:42

1、打开excel 点工具---点宏 -----点Visual Basic 编辑器

Excel 取出 文字 首字母

2、插入模块,点插入----点模块

Excel 取出 文字 首字母

3、将如下代码复制到刚才插入的模块中Public Function PY(TT A衡痕贤伎s String) As VariantDim i%, t髫潋啜缅emp$ PY = "" For i = 1 To Len(TT) temp = Asc(Mid$(TT, i, 1)) If temp > 255 Or temp < 0 Then PY = PY & pinyin(Mid$(TT, i, 1)) Else PY = PY & LCase(Mid$(TT, i, 1)) End If Next iEnd FunctionFunction pinyin(mystr As String) As Variant On Error Resume Next mystr = StrConv(mystr, vbNarrow) If Asc(mystr) > 0 Or Err.Number = 1004 Then pinyin1 = "" pinyin = Application.WorksheetFunction.VLookup(mystr, [{"啊","A";"八","B";"嚓","C";"搭","D";"蛾","E";"发","F";"噶","G";"铪","H";"击","J";"咔","K";"垃","L";"妈","M";"拿","N";"噢","O";"啪","P";"七","Q";"然","R";"仨","S";"他","T";"挖","W";"夕","X";"压","Y";"匝","Z"}], 2)End Function

Excel 取出 文字 首字母

4、在excel 单元格中输入函数 =PY(C2) 然后回车,就把C2中的文字首拼音显示出来了

Excel 取出 文字 首字母
Excel 取出 文字 首字母
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢