Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Ascii iinput file - separate text from Numbers

I have an input file that I would like to get into separate cells. The
data is something like this:

George Bush123456-78902
Abe Lincoln9876-543210
May Lou Rettin76543-2109713

I don't care about separating the first and Last name. What I need is
to determine when the number begins. Any ideas?

Thanks!!

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Ascii iinput file - separate text from Numbers

Kathy,

Don't know if this is the best way, but try this UDF. Put it in a regular
module in the workbook which contains the data you are trying to parse (Alt
F11, Insert Module, paste function below).

In a cell type: =GetNumericOnly(A1) where A1 = 1st cell of the data to parse.

'=====================================
Function GetNumericOnly(ByVal rng As Range)
On Error GoTo ErrorHandler
ReDim aArray(0)
sValue = rng
iLen = Len(rng)
d = 1
For C = 1 To iLen
sItem = Mid(sValue, C, 1)
If sItem Like "[0-9]" Then GoTo StoreValue
If sItem Like "-" Then GoTo StoreValue
GoTo NextItem
StoreValue:
ReDim Preserve aArray(d)
aArray(d) = sItem
d = d + 1
NextItem:
Next
For e = 1 To d - 1
sNewItem = sNewItem & aArray(e)
Next
Erase aArray
If sNewItem = "" Then GoTo ErrorHandler
GetNumericOnly = sNewItem
Exit Function
'---------------------
ErrorHandler:
GetNumericOnly = "#N/A"
End Function
'=====================================

Hope it helps. Good Luck.

MSweetG222


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 299
Default Ascii iinput file - separate text from Numbers

Is it always letters then finishing off with numbers in each string? if so

=MID(A1,MIN(IF(ISERR(FIND({1,2,3,4,5,6,7,8,9,0},A1 )),"",FIND({1,2,3,4,5,6,7,8,9,0},A1))),255)

will return the string from the first number to the end
Where Bush would be in A1, assume that you put the above formula in B1, then
in C1

=SUBSTITUTE(A1,B1,"")

will give you the name

--


Regards,

Peo Sjoblom

Excel 95 - Excel 2007
Northwest Excel Solutions
www.nwexcelsolutions.com
(remove ^^ from email)


wrote in message
oups.com...
I have an input file that I would like to get into separate cells. The
data is something like this:

George Bush123456-78902
Abe Lincoln9876-543210
May Lou Rettin76543-2109713

I don't care about separating the first and Last name. What I need is
to determine when the number begins. Any ideas?

Thanks!!



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Ascii iinput file - separate text from Numbers

Thanks - this worked perfectly!!!
MSweetG222 wrote:
Kathy,

Don't know if this is the best way, but try this UDF. Put it in a regular
module in the workbook which contains the data you are trying to parse (Alt
F11, Insert Module, paste function below).

In a cell type: =GetNumericOnly(A1) where A1 = 1st cell of the data to parse.

'=====================================
Function GetNumericOnly(ByVal rng As Range)
On Error GoTo ErrorHandler
ReDim aArray(0)
sValue = rng
iLen = Len(rng)
d = 1
For C = 1 To iLen
sItem = Mid(sValue, C, 1)
If sItem Like "[0-9]" Then GoTo StoreValue
If sItem Like "-" Then GoTo StoreValue
GoTo NextItem
StoreValue:
ReDim Preserve aArray(d)
aArray(d) = sItem
d = d + 1
NextItem:
Next
For e = 1 To d - 1
sNewItem = sNewItem & aArray(e)
Next
Erase aArray
If sNewItem = "" Then GoTo ErrorHandler
GetNumericOnly = sNewItem
Exit Function
'---------------------
ErrorHandler:
GetNumericOnly = "#N/A"
End Function
'=====================================

Hope it helps. Good Luck.

MSweetG222


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
Would Like to Automate Batch File Creation and Text FIle Import socrtwo Excel Discussion (Misc queries) 2 August 18th 06 03:54 PM
Text File sparx Excel Discussion (Misc queries) 3 April 25th 06 10:36 PM
Formulas dealing with text data Bagia Excel Worksheet Functions 6 June 20th 05 10:29 PM
how to save a file as ASCII: expanded comma delimited text (.exp). kmh Excel Discussion (Misc queries) 0 May 1st 05 01:05 AM
Convert text file to MS_Excel Aqua Flow Excel Discussion (Misc queries) 1 November 30th 04 02:55 AM


All times are GMT +1. The time now is 12:23 PM.

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"