Isolate Numerical Data in Cell
Option Explicit
Function Distance(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
With re
.IgnoreCase = True
.MultiLine = True
.Global = True
.Pattern = "[\s\S]+Distance:.(\b\d*\.?\d+\b)[\s\S]+"
End With
Distance = re.Replace(str, "$1")
End Function
Since we know the OP has a regional setting where the "dot" is the decimal
point...
Function Distance(str As String)
Distance = Val(Split(str, "Distance:", , vbTextCompare)(1))
End Function
Rick
|