Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bob
 
Posts: n/a
Default Truncating a text string

I would like to set up a formula that references a string in another cell but
truncates the beginning, middle, or end of it. The cell containing the data
always has five names separated by four commas, as shown below

Example:
A1 = Contains the text string "Simmons, Bogut, Magloire, Ford, Redd"
B1 = Want a formula that returns only the last two names in A1, "Ford, Redd"
C1 = Want a formula that returns only the first three names in A1, "Simmons,
Bogut, Magloire"
D1 = Want a formula that returns only the third name in A1, "Magloire"

Thank you for your help,
Bob
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David Billigmeier
 
Posts: n/a
Default Truncating a text string

In B1: =RIGHT(A1,LEN(A1)-1-SEARCH(",",A1,1+SEARCH(",",A1,1+SEARCH(",",A1))))
In C1: =SUBSTITUTE(A1,", "&B1,"")
In D1: =RIGHT(C1,LEN(C1)-1-SEARCH(",",C1,1+SEARCH(",",C1)))


--
Regards,
Dave


"bob" wrote:

I would like to set up a formula that references a string in another cell but
truncates the beginning, middle, or end of it. The cell containing the data
always has five names separated by four commas, as shown below

Example:
A1 = Contains the text string "Simmons, Bogut, Magloire, Ford, Redd"
B1 = Want a formula that returns only the last two names in A1, "Ford, Redd"
C1 = Want a formula that returns only the first three names in A1, "Simmons,
Bogut, Magloire"
D1 = Want a formula that returns only the third name in A1, "Magloire"

Thank you for your help,
Bob

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
CLR
 
Posts: n/a
Default Truncating a text string

I think I would use the Data TextToColumns, comma delimited, to separate
all five names into their own columns, and then CONCATENATE the ones I wanted
back together............

Vaya con Dios,
Chuck, CABGx3



"bob" wrote:

I would like to set up a formula that references a string in another cell but
truncates the beginning, middle, or end of it. The cell containing the data
always has five names separated by four commas, as shown below

Example:
A1 = Contains the text string "Simmons, Bogut, Magloire, Ford, Redd"
B1 = Want a formula that returns only the last two names in A1, "Ford, Redd"
C1 = Want a formula that returns only the first three names in A1, "Simmons,
Bogut, Magloire"
D1 = Want a formula that returns only the third name in A1, "Magloire"

Thank you for your help,
Bob

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
 
Posts: n/a
Default Truncating a text string

On Tue, 20 Dec 2005 11:31:04 -0800, bob wrote:

I would like to set up a formula that references a string in another cell but
truncates the beginning, middle, or end of it. The cell containing the data
always has five names separated by four commas, as shown below

Example:
A1 = Contains the text string "Simmons, Bogut, Magloire, Ford, Redd"
B1 = Want a formula that returns only the last two names in A1, "Ford, Redd"
C1 = Want a formula that returns only the first three names in A1, "Simmons,
Bogut, Magloire"
D1 = Want a formula that returns only the third name in A1, "Magloire"

Thank you for your help,
Bob


Two methods:

Using native Excel functions:

B1: =MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,",",CHAR(1),3)) +2,255)
C1: =LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1,",",CHAR(1),3) )-1)
D1: =MID(C1,FIND(CHAR(1),SUBSTITUTE(C1,",",CHAR(1),2)) +2,255)

Using regular expressions:

Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr/


B1: =REGEX.MID(A1,"\w+,\s\w+$")
C1: =REGEX.MID(A1,"\w+,\s\w+,\s\w+")
D1: =REGEX.MID(A1,"\w+",3)



--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
Find first numeric value in text string Rbp9ad Excel Worksheet Functions 4 October 15th 05 02:01 AM
Extracting integers from a text string. Bhupinder Rayat Excel Worksheet Functions 10 September 28th 05 05:15 PM
dynamic cell reference within a text string gvm Excel Worksheet Functions 4 July 25th 05 02:40 AM
Extracting from a text string AmyTaylor Excel Worksheet Functions 3 June 24th 05 01:34 PM
Formating a text string? METCO1 Excel Discussion (Misc queries) 2 November 30th 04 06:31 PM


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