Thread: Splitting text
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Splitting text

And for my FINAL faux-pas of the day, a version of the UDF that should work
much better, and more reliably than the other (which actually works, but
wasn't that well written).

Function GetDigits(whatCell As Range) As String
Dim srcString As String
Dim LC As Integer

GetDigits = ""
srcString = whatCell.Value
For LC = 1 To Len(srcString)
If Mid(srcString, LC, 1) = "0" And Mid(srcString, LC, 1) <= "9" Then
GetDigits = GetDigits & Mid(srcString, LC, 1)
Else
'must have hit non-digit, quit
Exit Function
End If
Next
End Function


"LLG-CN" wrote:

I have a spreadsheet that contains a column that has numbers and text of
varying lengths that I need to split into 2 columns.

Example: 123John Doe
1234Jane Doe

I can't split it using the Text To Columns function because there's nothing
delimited the text and the fixed width doesn't work because the numbers
preceeding the text are varying lengths.

Does anyone know a way to extract the data?
Is there something that extracts numerals vs characters?