View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default 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