
在excel表格里,能把一句话的首字母提取出来吗??
我这边excel表格里有一段文字,我需要提取每一个字的拼音首字母,求大神指导???(可以不在excel里,只要能提取首字母就行)...
我这边excel表格里有一段文字,我需要提取每一个字的拼音首字母,求大神指导???(可以不在excel里,只要能提取首字母就行)
展开
展开全部
1 转换成拼音,先把这段文字复制到 http://xh.5156edu.com/conversion.html 得到所有拼音
2 获取首字母
2.1 把拼音随便复制到excel里哪一格,例如复制到A1
2.2 把拼音间的空格替换成回车
在查找框内输入空格,在替换框内(通过按ctrl + f调出)输入:按住alt键不放,然后依次通过键盘上右侧的数字键盘输入1和0两个数字,放开数字键后再放开alt键。
输入以上按键时替换框内看不到变化,不要多输,也不要输少了。如果是用笔记本电脑,也不要用数字键输入10,必须调用字母按键上的数字小键盘才行。 EXCEl的查找、替换有记忆功能,若连续使用就不需再输入alt+10,可直接替换、查找。
2.3 双击A1,全选中被替换成很多行的拼音,复制。
2.4 选中B1,粘贴,会自动分成很多行
2.5 C1写公式 = LEFT(B1,1) 下拉
现在C列就是所有拼音首字母了
2 获取首字母
2.1 把拼音随便复制到excel里哪一格,例如复制到A1
2.2 把拼音间的空格替换成回车
在查找框内输入空格,在替换框内(通过按ctrl + f调出)输入:按住alt键不放,然后依次通过键盘上右侧的数字键盘输入1和0两个数字,放开数字键后再放开alt键。
输入以上按键时替换框内看不到变化,不要多输,也不要输少了。如果是用笔记本电脑,也不要用数字键输入10,必须调用字母按键上的数字小键盘才行。 EXCEl的查找、替换有记忆功能,若连续使用就不需再输入alt+10,可直接替换、查找。
2.3 双击A1,全选中被替换成很多行的拼音,复制。
2.4 选中B1,粘贴,会自动分成很多行
2.5 C1写公式 = LEFT(B1,1) 下拉
现在C列就是所有拼音首字母了
展开全部
'把下面的代码复制到VB环境的模块里,就可以象使用公式一样使用GetPy方法,获取所选单元格的每个字的首个拼音字母了。
Public Function GetPy(oSelection As Range) As String
Dim strTxt As String, strPy As String '文本内容,拼音
For Each omember In oSelection.Cells
'Selection.Count>1'多个单元格被选中
strTxt = omember.Text
If Len(strTxt) < 1 Then Exit For
strPy = strPy + GetPinY(strTxt)
Next
GetPy = strPy '返回所选区域所有汉字的首个拼音字母
End Function
'GetPinY是私有方法(Private ),供公有方法GetPy使用
Dim i As Long
For cx = 1 To Len(myStr)
If Asc(Mid(myStr, cx, 1)) < 0 Then '对汉字进行处理
i = Asc(Mid(myStr, cx, 1))
Select Case i
Case -20319 To -20284 'i >= Asc("啊") And i < Asc("芭")
GetPinY = GetPinY + "A"
Case -20283 To -19776 'i >= Asc("芭") And i < Asc("擦")
GetPinY = GetPinY + "B"
Case -19775 To -19219 'i >= Asc("擦") And i < Asc("搭")
GetPinY = GetPinY + "C"
Case -19218 To -18711 'i >= Asc("搭") And i < Asc("蛾")
GetPinY = GetPinY + "D"
Case -18710 To -18527 ' i >= Asc("蛾") And i < Asc("发")
GetPinY = GetPinY + "E"
Case -18526 To -18240 'i >= Asc("发") And i < Asc("噶")
GetPinY = GetPinY + "F"
Case -18239 To -17923 'i >= Asc("噶") And i < Asc("哈")
GetPinY = GetPinY + "G"
Case -17922 To -17418 'i >= Asc("哈") And i < Asc("击")
GetPinY = GetPinY + "H"
Case -17417 To -16475 ' i >= Asc("击") And i < Asc("喀")
GetPinY = GetPinY + "J"
Case -16474 To -16213 ' i >= Asc("喀") And i < Asc("垃")
GetPinY = GetPinY + "K"
Case -16212 To -15641 ' i >= Asc("垃") And i < Asc("妈")
GetPinY = GetPinY + "L"
Case -15640 To -15166 'i >= Asc("妈") And i < Asc("拿")
GetPinY = GetPinY + "M"
Case -15165 To -14923 ' i >= Asc("拿") And i < Asc("哦")
GetPinY = GetPinY + "N"
Case -14922 To -14915 'i >= Asc("哦") And i < Asc("啪")
GetPinY = GetPinY + "O"
Case -14914 To -14630 ' i >= Asc("啪") And i < Asc("欺")
GetPinY = GetPinY + "P"
Case -14629 To -14150 ' i >= Asc("欺") And i < Asc("然")
GetPinY = GetPinY + "Q"
Case -14149 To -14091 'i >= Asc("然") And i < Asc("撒")
GetPinY = GetPinY + "R"
Case -14090 To -13319 ' i >= Asc("撒") And i < Asc("塌")
GetPinY = GetPinY + "S"
Case -13318 To -12839 'i >= Asc("塌") And i < Asc("挖")
GetPinY = GetPinY + "T"
Case -12838 To -12557 ' i >= Asc("挖") And i < Asc("昔")
GetPinY = GetPinY + "W"
Case -12556 To -11848 'i >= Asc("昔") And i < Asc("压")
GetPinY = GetPinY + "X"
Case -11847 To -11056 'i >= Asc("压") And i < Asc("匝")
GetPinY = GetPinY + "Y"
Case -11055 To -10247 'i >= Asc("匝") And i <= Asc("座")
GetPinY = GetPinY + "Z"
Case Else '其它末识别汉字(比如繁体字),直接列出
GetPinY = GetPinY + Mid(myStr, cx, 1)
End Select
End If
Next
End Function
Public Function GetPy(oSelection As Range) As String
Dim strTxt As String, strPy As String '文本内容,拼音
For Each omember In oSelection.Cells
'Selection.Count>1'多个单元格被选中
strTxt = omember.Text
If Len(strTxt) < 1 Then Exit For
strPy = strPy + GetPinY(strTxt)
Next
GetPy = strPy '返回所选区域所有汉字的首个拼音字母
End Function
'GetPinY是私有方法(Private ),供公有方法GetPy使用
Dim i As Long
For cx = 1 To Len(myStr)
If Asc(Mid(myStr, cx, 1)) < 0 Then '对汉字进行处理
i = Asc(Mid(myStr, cx, 1))
Select Case i
Case -20319 To -20284 'i >= Asc("啊") And i < Asc("芭")
GetPinY = GetPinY + "A"
Case -20283 To -19776 'i >= Asc("芭") And i < Asc("擦")
GetPinY = GetPinY + "B"
Case -19775 To -19219 'i >= Asc("擦") And i < Asc("搭")
GetPinY = GetPinY + "C"
Case -19218 To -18711 'i >= Asc("搭") And i < Asc("蛾")
GetPinY = GetPinY + "D"
Case -18710 To -18527 ' i >= Asc("蛾") And i < Asc("发")
GetPinY = GetPinY + "E"
Case -18526 To -18240 'i >= Asc("发") And i < Asc("噶")
GetPinY = GetPinY + "F"
Case -18239 To -17923 'i >= Asc("噶") And i < Asc("哈")
GetPinY = GetPinY + "G"
Case -17922 To -17418 'i >= Asc("哈") And i < Asc("击")
GetPinY = GetPinY + "H"
Case -17417 To -16475 ' i >= Asc("击") And i < Asc("喀")
GetPinY = GetPinY + "J"
Case -16474 To -16213 ' i >= Asc("喀") And i < Asc("垃")
GetPinY = GetPinY + "K"
Case -16212 To -15641 ' i >= Asc("垃") And i < Asc("妈")
GetPinY = GetPinY + "L"
Case -15640 To -15166 'i >= Asc("妈") And i < Asc("拿")
GetPinY = GetPinY + "M"
Case -15165 To -14923 ' i >= Asc("拿") And i < Asc("哦")
GetPinY = GetPinY + "N"
Case -14922 To -14915 'i >= Asc("哦") And i < Asc("啪")
GetPinY = GetPinY + "O"
Case -14914 To -14630 ' i >= Asc("啪") And i < Asc("欺")
GetPinY = GetPinY + "P"
Case -14629 To -14150 ' i >= Asc("欺") And i < Asc("然")
GetPinY = GetPinY + "Q"
Case -14149 To -14091 'i >= Asc("然") And i < Asc("撒")
GetPinY = GetPinY + "R"
Case -14090 To -13319 ' i >= Asc("撒") And i < Asc("塌")
GetPinY = GetPinY + "S"
Case -13318 To -12839 'i >= Asc("塌") And i < Asc("挖")
GetPinY = GetPinY + "T"
Case -12838 To -12557 ' i >= Asc("挖") And i < Asc("昔")
GetPinY = GetPinY + "W"
Case -12556 To -11848 'i >= Asc("昔") And i < Asc("压")
GetPinY = GetPinY + "X"
Case -11847 To -11056 'i >= Asc("压") And i < Asc("匝")
GetPinY = GetPinY + "Y"
Case -11055 To -10247 'i >= Asc("匝") And i <= Asc("座")
GetPinY = GetPinY + "Z"
Case Else '其它末识别汉字(比如繁体字),直接列出
GetPinY = GetPinY + Mid(myStr, cx, 1)
End Select
End If
Next
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
网上有现成的代码。
下面的代码是自定义函数的。
要在Excel中使用,方法如下:
A1 A2
中国 =getpy(A1)
Function getpychar(char)
tmp = 65536 + Asc(char)
If (tmp >= 45217 And tmp <= 45252) Then
getpychar = "A"
ElseIf (tmp >= 45253 And tmp <= 45760) Then
getpychar = "B"
ElseIf (tmp >= 45761 And tmp <= 46317) Then
getpychar = "C"
ElseIf (tmp >= 46318 And tmp <= 46825) Then
getpychar = "D"
ElseIf (tmp >= 46826 And tmp <= 47009) Then
getpychar = "E"
ElseIf (tmp >= 47010 And tmp <= 47296) Then
getpychar = "F"
ElseIf (tmp >= 47297 And tmp <= 47613) Then
getpychar = "G"
ElseIf (tmp >= 47614 And tmp <= 48118) Then
getpychar = "H"
ElseIf (tmp >= 48119 And tmp <= 49061) Then
getpychar = "J"
ElseIf (tmp >= 49062 And tmp <= 49323) Then
getpychar = "K"
ElseIf (tmp >= 49324 And tmp <= 49895) Then
getpychar = "L"
ElseIf (tmp >= 49896 And tmp <= 50370) Then
getpychar = "M"
ElseIf (tmp >= 50371 And tmp <= 50613) Then
getpychar = "N"
ElseIf (tmp >= 50614 And tmp <= 50621) Then
getpychar = "O"
ElseIf (tmp >= 50622 And tmp <= 50905) Then
getpychar = "P"
ElseIf (tmp >= 50906 And tmp <= 51386) Then
getpychar = "Q"
ElseIf (tmp >= 51387 And tmp <= 51445) Then
getpychar = "R"
ElseIf (tmp >= 51446 And tmp <= 52217) Then
getpychar = "S"
ElseIf (tmp >= 52218 And tmp <= 52697) Then
getpychar = "T"
ElseIf (tmp >= 52698 And tmp <= 52979) Then
getpychar = "W"
ElseIf (tmp >= 52980 And tmp <= 53640) Then
getpychar = "X"
ElseIf (tmp >= 53689 And tmp <= 54480) Then
getpychar = "Y"
ElseIf (tmp >= 54481 And tmp <= 62289) Then
getpychar = "Z"
Else '如果不是中文,则不处理
getpychar = char
End If
End Function
Function getpy(str)
For i = 1 To Len(str)
getpy = getpy & getpychar(Mid(str, i, 1))
Next i
End Function
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在网上转换,这有网址看以试一下:http://www.aies.cn/pinyin.htm
追问
我是要提取首字母
追答
没必要那么复杂的,将拼音复制到excel单元格内,分列-分隔符号-勾选空格。
下一行第一个单元格内(即,若是A1为有拼音的单元格,则在B1)内输入 =left(A1,1)向右填充。
这样不就实现了
若是还想连起来只需要用&函数实现,如B1&B2&。。。,获得大写字母可以用upper()函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询