Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 383
Default Extract number from text/number string..

060705 Extract number from text/number string..

is there a way to make the following work? thanks

=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-8),SEARCH("<b<i",CC9)+3,255))

to extract: 0.16 from: (formula above gets #Value error)
<i11:19am</i - <b<i0.16</i</b

----------
other variation, have formula that works for different input:
=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-4),SEARCH("<b",CC9)+3,255))

11:35am - <b0.5601</b
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Extract number from text/number string..

<b<i
is no longer 3 characters.



nastech wrote:

060705 Extract number from text/number string..

is there a way to make the following work? thanks

=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-8),SEARCH("<b<i",CC9)+3,255))

to extract: 0.16 from: (formula above gets #Value error)
<i11:19am</i - <b<i0.16</i</b

----------
other variation, have formula that works for different input:
=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-4),SEARCH("<b",CC9)+3,255))

11:35am - <b0.5601</b


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Extract number from text/number string..

On Wed, 5 Jul 2006 11:49:01 -0700, nastech
wrote:

060705 Extract number from text/number string..

is there a way to make the following work? thanks

=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-8),SEARCH("<b<i",CC9)+3,255))

to extract: 0.16 from: (formula above gets #Value error)
<i11:19am</i - <b<i0.16</i</b

----------
other variation, have formula that works for different input:
=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-4),SEARCH("<b",CC9)+3,255))

11:35am - <b0.5601</b


Depending on the criteria used to define "number", you could do it with Regular
Expressions.

At it's simplest, if the number you wish to extract will always have

At least one digit
Decimal point
At least one digit

and there will be no other similar sequences prior to the number you wish to
extract, the regular expression "\d+\.\d+" would define it.

You can use Regular Expressions in Excel by downloading and installing Longre's
free morefunc.xll add-in from http://xcell05.free.fr/

Then use the formula:

=REGEX.MID(A1,"\d+\.\d+")

If the possibilities for the number are more complex, then a Regular Expression
can be crafted to take that into account.


--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 383
Default Extract number from text/number string..

Thanks Dave, that worked:
came up with the following, let me know if see anything wrong

=IF(CD9="","",IF(LEFT(CD9,3)<"<i",
--MID(LEFT(CD9,LEN(CD9)-4),SEARCH("<b",CD9)+3,255),
--MID(LEFT(CD9,LEN(CD9)-8),SEARCH("<b<i",CD9)+6,255)))

works for both:
11:35am - <b0.5601</b <i11:19am</i - <b<i1111.16</i</b

for others, was working on extracting number from variations:
<i11:19am</i - <b<i0.16</i</b
11:35am - <b0.5601</b
11:35am - <b10.56</b
11:35am - <b1111.5601</b


"Dave Peterson" wrote:

<b<i
is no longer 3 characters.



nastech wrote:

060705 Extract number from text/number string..

is there a way to make the following work? thanks

=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-8),SEARCH("<b<i",CC9)+3,255))

to extract: 0.16 from: (formula above gets #Value error)
<i11:19am</i - <b<i0.16</i</b

----------
other variation, have formula that works for different input:
=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-4),SEARCH("<b",CC9)+3,255))

11:35am - <b0.5601</b


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 383
Default Extract number from text/number string..

thank you very much, will check that out. see above for what was working
on.. thanks..

"Ron Rosenfeld" wrote:

On Wed, 5 Jul 2006 11:49:01 -0700, nastech
wrote:

060705 Extract number from text/number string..

is there a way to make the following work? thanks

=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-8),SEARCH("<b<i",CC9)+3,255))

to extract: 0.16 from: (formula above gets #Value error)
<i11:19am</i - <b<i0.16</i</b

----------
other variation, have formula that works for different input:
=IF(CC9="","",--MID(LEFT(CC9,LEN(CC9)-4),SEARCH("<b",CC9)+3,255))

11:35am - <b0.5601</b


Depending on the criteria used to define "number", you could do it with Regular
Expressions.

At it's simplest, if the number you wish to extract will always have

At least one digit
Decimal point
At least one digit

and there will be no other similar sequences prior to the number you wish to
extract, the regular expression "\d+\.\d+" would define it.

You can use Regular Expressions in Excel by downloading and installing Longre's
free morefunc.xll add-in from http://xcell05.free.fr/

Then use the formula:

=REGEX.MID(A1,"\d+\.\d+")

If the possibilities for the number are more complex, then a Regular Expression
can be crafted to take that into account.


--ron



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Extract number from text/number string..

On Wed, 5 Jul 2006 13:02:01 -0700, nastech
wrote:

thank you very much, will check that out. see above for what was working
on.. thanks..


The formula I posted works on all those examples, for what it's worth.


--ron
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
Pulling Data off Web - Need Function Help patfergie44 Excel Worksheet Functions 9 June 22nd 06 03:27 AM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
EXTRACT NUMBERS FROM TEXT STRING fiber_doc Excel Worksheet Functions 4 November 28th 05 06:40 PM
Calculating number of letters in a string ... Larry Wallis Excel Discussion (Misc queries) 4 February 17th 05 10:11 AM
Calculating number of letters in a string ... Larry Wallis Excel Worksheet Functions 4 February 17th 05 10:11 AM


All times are GMT +1. The time now is 04:08 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"