
Originally Posted by
sjk1193
...just looking for the most robust solution
This macro will do what you want even if there is no space between the leading number and the text following it and it preserve leading zeros too...
Sub FiveDigitOrMore()
Dim R As Long, X As Long, Data As Variant
Data = Range("A1", Cells(Rows.Count, "A").End(xlUp))
For R = 1 To UBound(Data)
If Data(R, 1) Like "#####*" Then
For X = 6 To Len(Data(R, 1))
If Mid(Data(R, 1), X, 1) Like "[!0-9]" Then Data(R, 1) = Left(Data(R, 1), X - 1)
Next
End If
Next
With Range("B1").Resize(UBound(Data))
.NumberFormat = "@"
.Value = Data
End With
End Sub
Bookmarks