如何用Excel从字母数字字符串中提取数字

如题所述

可以利用自定义函数,从字母数字字符串中,提取数字。

软件版本:Office2007

方法如下:

1.从A列字符串中提取数字:

2.Alt+F11,在右侧空白处点击右键,插入模块:

3.在模块中输入代码如下:

4.返回Excel,利用自定义的“取数字”函数,就可以得到结果:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-05-02
按ALT+F11,插入-模块,复制下列语句
FunctionSplitNumEng(str As String, sty As Byte)
Dim StrA As String
Dim StrB As String
Dim StrC As String
Dim i As Integer
Dim SigS As String
For i = 1 To Len(str)
SigS = Mid(str, i, 1)
If SigS Like "[a-zA-Z]" Then
StrA = StrA & SigS
ElseIf SigS Like "#" Then
StrB = StrB & SigS
Else
StrC = StrC & SigS
End If
Next i
Select Case sty
Case 1
SplitNumEng = StrA
Case 2
SplitNumEng = StrB
Case Else
SplitNumEng = StrC
End Select
EndFunction

比如你的数据在A1
B1输入
=SplitNumEng(A1,2)
下拉公式即可本回答被提问者采纳