+ -
当前位置:首页 → 问答吧 → 有冇excel达人??有野请教!

有冇excel达人??有野请教!

时间:2013-12-02

来源:互联网

有组字元系混合左文字同数字,例如appl33eg00d
有咩做法可以将文字同数字分开,或者抽出数字,变成applegd?

作者: arrowsman2   发布时间: 2013-12-02

You may try the following VBA code, with the variable "txt" as the input, "num" return the numeric part and "other" returns the remaining part
复制内容到剪贴板代码:Sub Separate()
Dim txt As String, num As String, other As String
txt = "appl33eg00d"
num = ""
other = ""
For i = 1 To Len(txt)
If IsNumeric(Mid(txt, i, 1)) Then
num = num & Mid(txt, i, 1)
Else
other = other & Mid(txt, i, 1)
End If
Next i
MsgBox ("Num = " & num & " Other = " & other)
End Sub
[ 本帖最后由 BGM 於 2013-10-2 01:11 AM 编辑 ]

作者: BGM   发布时间: 2013-12-02