Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Christophe
 
Posts: n/a
Default Parsing 124A into 124

Hello:
I am looking for a way to parse the examples below in excel:
124 A into 124
12345 into 12345
55/49 into 55
888b into 888

Does such function exist in excel or any idea how I could implement it
in VBA? The longest serie of digits before a non numeric character is
what I am looking for.

Thanks a lot,
Chris

  #2   Report Post  
JMB
 
Posts: n/a
Default

one way, assuming the data is in cell B3

=IF(NOT(ISERROR(VALUE(B3))),B3,LEFT(B3,MATCH(0,(CO DE(MID(B3,ROW(INDIRECT("1:"&LEN(B3))),1))47)*(COD E(MID(B3,ROW(INDIRECT("1:"&LEN(B3))),1))<58)*ROW(I NDIRECT("1:"&LEN(B3))),0)-1))

when you enter the formula, you must hit Cntrl+Shift+Enter.



"Christophe" wrote:

Hello:
I am looking for a way to parse the examples below in excel:
124 A into 124
12345 into 12345
55/49 into 55
888b into 888

Does such function exist in excel or any idea how I could implement it
in VBA? The longest serie of digits before a non numeric character is
what I am looking for.

Thanks a lot,
Chris


  #3   Report Post  
JMB
 
Posts: n/a
Default

a little bit shorter

=IF(NOT(ISERROR(VALUE(B3))),B3,LEFT(B3,MATCH(0,(CO DE(MID(B3,ROW(INDIRECT("1:"&LEN(B3))),1))47)*(COD E(MID(B3,ROW(INDIRECT("1:"&LEN(B3))),1))<58),0)-1))

"Christophe" wrote:

Hello:
I am looking for a way to parse the examples below in excel:
124 A into 124
12345 into 12345
55/49 into 55
888b into 888

Does such function exist in excel or any idea how I could implement it
in VBA? The longest serie of digits before a non numeric character is
what I am looking for.

Thanks a lot,
Chris


  #4   Report Post  
Ron Moore
 
Posts: n/a
Default

Another possible array formula (entered with CTRL-SHIFT-ENTER), for data in A1:

=MAX(IF(ISNUMBER(--LEFT(A1,ROW($1:$50))),--LEFT(A1,ROW($1:$50))))

If necessary replace both occurrences of 50 with a sensible upper limit for
the string lengths you have.

"Christophe" wrote:

Hello:
I am looking for a way to parse the examples below in excel:
124 A into 124
12345 into 12345
55/49 into 55
888b into 888

Does such function exist in excel or any idea how I could implement it
in VBA? The longest serie of digits before a non numeric character is
what I am looking for.

Thanks a lot,
Chris


  #5   Report Post  
Harlan Grove
 
Posts: n/a
Default

"Ron Moore" wrote...
Another possible array formula (entered with CTRL-SHIFT-ENTER), for
data in A1:

=MAX(IF(ISNUMBER(--LEFT(A1,ROW($1:$50))),--LEFT(A1,ROW($1:$50))))

If necessary replace both occurrences of 50 with a sensible upper
limit for the string lengths you have.

....

There's not much gained using 50 rather than 1000 (or 10). Also, there's a
difference between locating the leftmost longest substring that could be
converted into a number and the leftmost longest substring of decimal
digits. Your formula returns errors when the first character is either a
dash or period followed by decimal digits.

As an alternative,

=--LEFT(A1,LOOKUP(1E300,-LEFT(A1,ROW($1:$50)),ROW($1:$50)))

which doesn't need to be entered as an array formula.




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
Parsing in Excel? DavidMunday Excel Worksheet Functions 1 August 4th 10 04:34 AM
Parsing 124A into 124 Christophe Excel Worksheet Functions 3 September 27th 05 07:36 PM
Data parsing question Dan Neely Excel Worksheet Functions 0 July 19th 05 12:40 AM
Parsing when deliminator is a string Rose Excel Worksheet Functions 5 December 14th 04 12:54 AM
Parsing text in Excel Jack Edwards Excel Worksheet Functions 3 November 4th 04 03:54 PM


All times are GMT +1. The time now is 03:27 AM.

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

About Us

"It's about Microsoft Excel"