Here is UDF you can use:
How to use:Code:Function LMP_ExtractValue1(ByVal Text As Range) Dim RegExp As Object Dim allMatches As Object Dim Result As String Set RegExp = CreateObject("vbscript.regexp") RegExp.Pattern = ".*?(\d{1,3}(\.\d{1,3}){3})|.*" Set allMatches = RegExp.Execute(Text) If LenB(Trim(Text)) > 0 Then If allMatches.Count <> 0 Then Result = allMatches.Item(0).submatches.Item(0) End If Else Result = CVErr(xlErrValue) End If LMP_ExtractValue1 = Result End Function
Code:=LMP_ExtractValue1(A1)
How to use:Code:Function LMP_ExtractValue2(ByVal Text As Range) Dim RegExp As Object Dim allMatches As Object Dim Result As String Set RegExp = CreateObject("vbscript.regexp") RegExp.Pattern = "((\:[0-9,A-Z,a-z]|[0-9,A-Z,a-z]{1,2}){11})" Set allMatches = RegExp.Execute(Text) If LenB(Trim(Text)) > 0 Then If allMatches.Count <> 0 Then Result = allMatches.Item(0).submatches.Item(0) End If Else Result = CVErr(xlErrValue) End If LMP_ExtractValue2 = Result End Function
Code:=LMP_ExtractValue2(A1)




Reply With Quote
Bookmarks