Extract Numeric Value From Alphanumeric Text Using VBA RegExp
In continuation to the Excel formula based solution given at http://www.excelfox.com/forum/f13/ex...eric-text-186/, here's one using VBA regular expression
Code:
Function ExtractNumFromAlphaNum(strAlNum As String) As Long
Const strPatter As String = "[\d+]"
Dim var, strOutput As String
With CreateObject("vbscript.regexp")
.Pattern = strPatter
.Global = True
Set var = .Execute(strAlNum)
For Each var In var
strOutput = strOutput & var
Next var
End With
ExtractNumFromAlphaNum = strOutput
End Function