If you have a nine digit number preceded by a larger string of numbers, this UDF might be of use.
Option Explicit
Function ReturnDigits(ByVal rng, NumberOfDigits As Integer)
Dim n As Integer
Dim arrDigits As Variant
ReturnDigits = ""
For n = 1 To Len(rng)
If Asc(Mid(rng, n, 1)) < 48 Or Asc(Mid(rng, n, 1)) > 57 Then
Mid(rng, n, 1) = " "
End If
Next
arrDigits = Split(WorksheetFunction.Trim(rng), " ")
For n = LBound(arrDigits) To UBound(arrDigits)
If Len(arrDigits(n)) = NumberOfDigits Then
ReturnDigits = arrDigits(n)
Exit For
End If
Next
End Function
Enter as e.g.
By changing the second arguement you can search for the first string of digits that match that length exactly.
Bookmarks