前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Excel 提取姓名首字母公式

Excel 提取姓名首字母公式

作者头像
QAIU
发布2023-03-14 15:25:37
1.5K0
发布2023-03-14 15:25:37
举报
文章被收录于专栏:手机编程手机编程

#Excel 提取姓名首字母公式

1. 公式

  1. 无法区分多音字
  2. 个别字和生僻字识别有误 因此需要手动校对
代码语言:javascript
复制
=VLOOKUP(MID(C2,1,1),{"",0;"吖","A";"八","B";"攃","C";"咑","D";"鵽","E";"发","F";"旮","G";"哈","H";"丌","J";"咔","K";"垃","L";"妈","M";"乸","N";"噢","O";"帊","P";"七","Q";"冄","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"},2)&VLOOKUP(MID(C2,2,1),{"",0;"吖","A";"八","B";"攃","C";"咑","D";"鵽","E";"发","F";"旮","G";"哈","H";"丌","J";"咔","K";"垃","L";"妈","M";"乸","N";"噢","O";"帊","P";"七","Q";"冄","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"},2)&(IF(LEN(C2)>2,VLOOKUP(MID(C2,3,1),{"",0;"吖","A";"八","B";"攃","C";"咑","D";"鵽","E";"发","F";"旮","G";"哈","H";"丌","J";"咔","K";"垃","L";"妈","M";"乸","N";"噢","O";"帊","P";"七","Q";"冄","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"},2),""))

2. VBS宏

不支持WPS个人版(免费)

代码语言:javascript
复制
Function Getpychar(char)

temp = 65536 + Asc(char)

If (temp >= 45217 And temp <= 45252) Then

Getpychar = "A"

ElseIf (temp >= 45253 And temp <= 45760) Then

Getpychar = "B"

ElseIf (temp >= 45761 And temp <= 46317) Then

Getpychar = "C"

ElseIf (temp >= 46318 And temp <= 46825) Then

Getpychar = "D"

ElseIf (temp >= 46826 And temp <= 47009) Then

Getpychar = "E"

ElseIf (temp >= 47010 And temp <= 47296) Then

Getpychar = "F"

ElseIf (temp >= 47297 And temp <= 47613) Then

Getpychar = "G"

ElseIf (temp >= 47614 And temp <= 48118) Then

Getpychar = "H"

ElseIf (temp >= 48119 And temp <= 49061) Then

Getpychar = "J"

ElseIf (temp >= 49062 And temp <= 49323) Then

Getpychar = "K"

ElseIf (temp >= 49324 And temp <= 49895) Then

Getpychar = "L"

ElseIf (temp >= 49896 And temp <= 50370) Then

Getpychar = "M"

ElseIf (temp >= 50371 And temp <= 50613) Then

Getpychar = "N"

ElseIf (temp >= 50614 And temp <= 50621) Then

Getpychar = "O"

ElseIf (temp >= 50622 And temp <= 50905) Then

Getpychar = "P"

ElseIf (temp >= 50906 And temp <= 51386) Then

Getpychar = "Q"

ElseIf (temp >= 51387 And temp <= 51445) Then

Getpychar = "R"

ElseIf (temp >= 51446 And temp <= 52217) Then

Getpychar = "S"

ElseIf (temp >= 52218 And temp <= 52697) Then

Getpychar = "T"

ElseIf (temp >= 52698 And temp <= 52979) Then

Getpychar = "W"

ElseIf (temp >= 52980 And temp <= 53640) Then

Getpychar = "X"

ElseIf (temp >= 53689 And temp <= 54480) Then

Getpychar = "Y"

ElseIf (temp >= 54481 And temp <= 62289) Then

Getpychar = "Z"

Else

Getpychar = char

End If

End Function

Function Getpy(str)

For a = 1 To Len(str)

Getpy = Getpy & Getpychar(Mid(str, a, 1))

Next a

End Function
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-01-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. 公式
    • 2. VBS宏
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档