最近,我的好朋友赵某为了追一个女孩,答应帮女孩整理excel文档,功能需求是吧姓名的首字母提取出来。他百度了不会,随即找我来请教。我在百度查了一下方法,大多数都是要启用宏,使用vba插件,这么复杂的方法怎么会适合去显呗呢,所以我决定帮助他用函数解决这个问题:

首先在网上查找到的一种方法 ,只能提取第一个汉字的首字母,方法如下:

=LOOKUP(CODE(LEFT(B6)),45217+{0,36,544,1101,1609,1793,2080,2560,2902,3845,4107,4679,5154,5397,5405,5689,6170,6229,7001,7481,7763,8472,9264},{“A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”W”,”X”,”Y”,”Z”})

让赵某看了之后,他说不行,要提取每一个汉字的首字母,于是我只好把这个方法给改一下,结果改出来了获取最后一个汉字的首字母:

=LOOKUP(CODE(RIGHT(B6)),45217+{0,36,544,1101,1609,1793,2080,2560,2902,3845,4107,4679,5154,5397,5405,5689,6170,6229,7001,7481,7763,8472,9264},{“A”,”B”,”C”,”D”,”E”,”F”,”G”,”H”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”W”,”X”,”Y”,”Z”})

查了下相关的函数,发现CODE不能实现想要的效果,于是有查找相关的函数,发现可以使用MID()函数,使用MID函数之后,获取首字母的数字方法就不能使用了,于是在网上查找了另外一种方法,最终用vlook()函数实现了,提取每个汉字首字母的方法:

=VLOOKUP(MID(A2,1,1),{“”,””;”吖”,”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(A2,1,1),{“”,””;”吖”,”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(A2,2,1),{“”,””;”吖”,”A”;”八”,”B”;”攃”,”C”;”咑”,”D”;”鵽”,”E”;”发”,”F”;”旮”,”G”;”哈”,”H”;”丌”,”J”;”咔”,”K”;”垃”,”L”;”妈”,”M”;”乸”,”N”;”噢”,”O”;”帊”,”P”;”七”,”Q”;”冄”,”R”;”仨”,”S”;”他”,”T”;”屲”,”W”;”夕”,”X”;”丫”,”Y”;”帀”,”Z”},2)

如果要提现三个,就在拼接一次,依次类推,想要提取几个汉字的首字母就拼接几次这个方法,,例如我提取5个汉字的首字母,方法如下:

=VLOOKUP(MID(A1,1,1),A1{“”,””;”吖”,”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(A1,2,1),{“”,””;”吖”,”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(A1,3,1),{“”,””;”吖”,”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(A1,4,1),{“”,””;”吖”,”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(A1,5,1),{“”,””;”吖”,”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(A1,6,1),{“”,””;”吖”,”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(A1,1,1),{“”,””;”啊”,”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(A1,2,1),{“”,””;”啊”,”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(A1,3,1),{“”,””;”啊”,”a”;”芭”,”b”;”擦”,”c”;”搭”,”d”;”蛾”,”e”;”发”,”f”;”噶”,”g”;”哈”,”h”;”击”,”j”;”喀”,”k”;”垃”,”l”;”妈”,”m”;”拿”,”n”;”哦”,”o”;”啪”,”p”;”期”,”q”;”然”,”r”;”撒”,”s”;”塌”,”t”;”挖”,”w”;”昔”,”x”;”压”,”y”;”匝”,”z”},2)

最后,配上效果图,希望能帮助到有需要的朋友。