#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Splitting text

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?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Splitting text

Hi,

With your string in a1 put this in B1 to extract the numbers

=LOOKUP(10^23,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345 6789")),ROW(INDIRECT("1:"&LEN(A1)))))

Then this in c1 to extract the name
=RIGHT(A1,LEN(A1)-LEN(B1))

Drag down as required

Mike

"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?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Splitting text

Someone may come along with a formula to replace my use of a User Defined
Function (UDF), which would be a better deal for you, but here's my solution.

First I created a UDF that finds the digits at the left side of the entry
(assumes your data is all like your examples). That UDF is put into a cell.
Then a regular cell formula is put into another cell to get whatever is left
from the original and display it. You'll understand better when you see it.

First, the UDF. Use [Alt]+[F11] to enter the VB Editor and choose Insert |
Module when you get there. Copy the code below and paste it into the empty
module presented to you. Close the VB Editor.

Lets say that 123John Doe is in cell A1, then in B1 put this formula:
=GetDigits(A1)
and in C1 put this formula
=RIGHT(A1,LEN(A1)-LEN(B1))

You should see 123 in B1 and John Doe in C1.

Hope this helps.

"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?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Splitting text

OOPS!! Here's the UDF you need:

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?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Splitting text

Hi,

Try

=LEFT(A1,MATCH(TRUE,ISERR(--MID(A1,ROW($1:$1000),1)),0)-1)
=MID(A1,MATCH(TRUE,ISERR(--MID(A1,ROW($1:$1000),1)),0),100)

Both array entered - press Shift+Ctrl+Enter to enter them

If this helps, please click the Yes button,

Cheers,
Shane Devenshire

"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?



  #6   Report Post  
Posted to microsoft.public.excel.misc
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?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Splitting text

Thanks for all the help.
The formula Mike H submitted worked like a charm and was very simple and
straight forward.

Thanks so much!

"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?

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Splitting text

Thanks, this worked just like I needed it to and was very simple.

"Mike H" wrote:

Hi,

With your string in a1 put this in B1 to extract the numbers

=LOOKUP(10^23,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345 6789")),ROW(INDIRECT("1:"&LEN(A1)))))

Then this in c1 to extract the name
=RIGHT(A1,LEN(A1)-LEN(B1))

Drag down as required

Mike

"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?

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Splitting text

Glad I could help with a 'simple' formula!

Mike

"LLG-CN" wrote:

Thanks, this worked just like I needed it to and was very simple.

"Mike H" wrote:

Hi,

With your string in a1 put this in B1 to extract the numbers

=LOOKUP(10^23,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345 6789")),ROW(INDIRECT("1:"&LEN(A1)))))

Then this in c1 to extract the name
=RIGHT(A1,LEN(A1)-LEN(B1))

Drag down as required

Mike

"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?

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Splitting text

Well, yes, simple is relative. Maybe short was a better term.
I would probably have never figured this one out.

"Mike H" wrote:

Hi,

With your string in a1 put this in B1 to extract the numbers

=LOOKUP(10^23,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"012345 6789")),ROW(INDIRECT("1:"&LEN(A1)))))

Then this in c1 to extract the name
=RIGHT(A1,LEN(A1)-LEN(B1))

Drag down as required

Mike

"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?



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Splitting text

On Wed, 12 Nov 2008 08:10:00 -0800, JLatham <HelpFrom @
Jlathamsite.com.(removethis) wrote:

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


Since the will always be at the beginning of the string, in this instance you
could use the Val function:

=============================
Option Explicit
Sub GetDigits()
Dim rg As Range, c As Range
Set rg = Selection

For Each c In rg
c.Offset(0, 1).Value = Val(Trim(c.Value))
Next c

End Sub
========================
--ron
  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Splitting text

See, I was right - someone came along (probably typing at the same time I
was) with a formula vs the UDF, and that's generally less cumbersome to work
with.

"LLG-CN" wrote:

Thanks for all the help.
The formula Mike H submitted worked like a charm and was very simple and
straight forward.

Thanks so much!

"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?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Splitting Text John Calder New Users to Excel 4 July 27th 07 04:00 AM
Splitting a delimited text atledreier Excel Discussion (Misc queries) 6 July 6th 07 08:16 AM
Splitting text to columns nospaminlich Excel Worksheet Functions 5 February 6th 06 09:26 PM
splitting text in a cell.. via135 Excel Discussion (Misc queries) 5 December 23rd 05 01:04 AM
Splitting Up Text in One Cell To Many Bert_Lady Excel Worksheet Functions 3 December 9th 05 01:55 AM


All times are GMT +1. The time now is 10:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"