Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 103
Default Extract specific value from a long text string

Hi,

I like to extract a value at the end of text string. The long text string
ends with "Inc. for - 356989.23".

Is there a formula where I can just extract the value of "356989.23"
only.The values can in hundreds, thousands, millions, but there is always a
space between a hyphen and where the value start.

Thanks

Dinesh
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Extract specific value from a long text string

One try ..
Assuming data in A1 down
In B1, copied down:
=MID(A1,SEARCH("- ",A1)+1,99)+0
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Dinesh" wrote:
Hi,

I like to extract a value at the end of text string. The long text string
ends with "Inc. for - 356989.23".

Is there a formula where I can just extract the value of "356989.23"
only.The values can in hundreds, thousands, millions, but there is always a
space between a hyphen and where the value start.

Thanks

Dinesh

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 103
Default Extract specific value from a long text string

Hi Max,

Thanks, It worked. but what if the string does not have the string "- ", it
gave an error of "#value!"?

"Max" wrote:

One try ..
Assuming data in A1 down
In B1, copied down:
=MID(A1,SEARCH("- ",A1)+1,99)+0
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Dinesh" wrote:
Hi,

I like to extract a value at the end of text string. The long text string
ends with "Inc. for - 356989.23".

Is there a formula where I can just extract the value of "356989.23"
only.The values can in hundreds, thousands, millions, but there is always a
space between a hyphen and where the value start.

Thanks

Dinesh

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Extract specific value from a long text string

"Dinesh" wrote:
Thanks, It worked. but what if the string does not have the string "- ", it
gave an error of "#value!"?


Then it would fail, but of course. The core assumption made was the
existence of the string "- ", as interp'd from your original posts' line:
but there is always a
space between a hyphen and where the value start.


Maybe hang around awhile for better insights from others for a generic
solution which could work to strip out the numbers irrespective. Or put in a
new post showing all the different types of sample text strings present, and
the expected results for each.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Extract specific value from a long text string

On Wed, 9 Aug 2006 18:14:02 -0700, Dinesh
wrote:

Hi,

I like to extract a value at the end of text string. The long text string
ends with "Inc. for - 356989.23".

Is there a formula where I can just extract the value of "356989.23"
only.The values can in hundreds, thousands, millions, but there is always a
space between a hyphen and where the value start.

Thanks

Dinesh



The format of the string is important.

Is it always the last number in the string?
Is the number always positive, or might it be negative, also?
Is the number always at the end of the string, or could there be text following
the number?

Will the number always have digits to the left of the decimal?

One way would be to download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr/ and use a Regular Expression.

If it is always the last value in the string, and will always have digits to
the left of the decimal,and always a positive number, then:

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

If there could be non-numeric characters following the number, and if it could
also be negative, and if there might not be any digits to the left of the
decimal, then:

=REGEX.MID(A1,"-?(\d+(\.\d*)?|\.\d+)",-1)

would probably due the trick.

If you need to return the value as a number (and not a text string),then
something like:

=IF(ISNUMBER(-REGEX.MID(A1,"\d+(\.\d*)?$")),--REGEX.MID(A1,"\d+(\.\d*)?$"),"")


--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
Error: The text string you entered is too long. GTVT06 Excel Discussion (Misc queries) 0 June 16th 06 06:41 PM
Find & Replace text format jmn13 Excel Discussion (Misc queries) 2 May 25th 06 06:18 PM
Conditional Format as a MACRO Gunjani Excel Worksheet Functions 3 March 29th 06 05:22 PM
EXTRACT NUMBERS FROM TEXT STRING fiber_doc Excel Worksheet Functions 4 November 28th 05 06:40 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 05:28 PM.

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"