Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How can I isolate the last two words in a text string?

I have found a formula that works great for retrieving the last word from a
string of charactors in a cell.
If the string in Cell A1 is: "How do I return the last two words?", the
formula below will give me the last word. (Isn't it nice sometimes to have
the last word?)

{=RIGHT(A1,MATCH(" ",MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1))),1),0))}
This will return "words?".

How can I modify this or, what other formula will return, "two words?".

I think this is a very slick formula, but I don't quite understand it well
enough to figure out how to modify the match to find the second blank.

Note: I found this formula in Osborne, THE COMPLETE REFERENCE EXCEL 2000 by
Kathy Ivens and Conrad Carlberg.
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default How can I isolate the last two words in a text string?

Thank you Niek, Your solution works great!
JE, I got an error message that there were too many arguments. I double and
triple checked my typing. Your solution is different than Niek's. I would
like to see yours work. Please check the solution. If it is right, then I
will try it again. Thanks.

"Steve Gibbs" wrote:

I have found a formula that works great for retrieving the last word from a
string of charactors in a cell.
If the string in Cell A1 is: "How do I return the last two words?", the
formula below will give me the last word. (Isn't it nice sometimes to have
the last word?)

{=RIGHT(A1,MATCH(" ",MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1))),1),0))}
This will return "words?".

How can I modify this or, what other formula will return, "two words?".

I think this is a very slick formula, but I don't quite understand it well
enough to figure out how to modify the match to find the second blank.

Note: I found this formula in Osborne, THE COMPLETE REFERENCE EXCEL 2000 by
Kathy Ivens and Conrad Carlberg.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,624
Default How can I isolate the last two words in a text string?

Quadruple check it (or paste from the message). It works.

In article ,
Steve Gibbs wrote:

JE, I got an error message that there were too many arguments. I double and
triple checked my typing.



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default How can I isolate the last two words in a text string?

I recieved four different solutions to my problem. All four work. This
solution is the shortest, least complicated and works the best. Testing the
solution with different strings consisting of one word, two word, three word,
and longer sentances, this is the only solution that would return a single
word in an one word sentance. If a blind space exists at the end of a word
only Niek Otten's solution would return the last two words. If there are two
blind spaces ant the end of the sentance none of the solutions return any
words. For my purpose Ron Rosenfeld's solution was best. Thanks.

"Ron Rosenfeld" wrote:

On Sun, 23 Nov 2008 14:29:01 -0800, Steve Gibbs <Steve
wrote:

I have found a formula that works great for retrieving the last word from a
string of charactors in a cell.
If the string in Cell A1 is: "How do I return the last two words?", the
formula below will give me the last word. (Isn't it nice sometimes to have
the last word?)

{=RIGHT(A1,MATCH(" ",MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1))),1),0))}
This will return "words?".

How can I modify this or, what other formula will return, "two words?".

I think this is a very slick formula, but I don't quite understand it well
enough to figure out how to modify the match to find the second blank.

Note: I found this formula in Osborne, THE COMPLETE REFERENCE EXCEL 2000 by
Kathy Ivens and Conrad Carlberg.


So long as your words are some reasonable length, something like:

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",99)),198))

will return the last two words.
--ron

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default How can I isolate the last two words in a text string?

On Fri, 28 Nov 2008 09:14:00 -0800, Steve Gibbs
wrote:

I recieved four different solutions to my problem. All four work. This
solution is the shortest, least complicated and works the best. Testing the
solution with different strings consisting of one word, two word, three word,
and longer sentances, this is the only solution that would return a single
word in an one word sentance. If a blind space exists at the end of a word
only Niek Otten's solution would return the last two words. If there are two
blind spaces ant the end of the sentance none of the solutions return any
words. For my purpose Ron Rosenfeld's solution was best. Thanks.


Thanks for the feedback.

Please make this small change in my contribution -- it will get rid of the
trailing spaces problem and should have been there originally:

=TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",99)),198))

--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
isolate date from a text string into another cell Tacrier Excel Discussion (Misc queries) 5 October 11th 08 12:00 AM
Extracting the last set of words from a text string IPerlovsky Excel Worksheet Functions 14 March 2nd 07 02:47 AM
How do I do a multiple search using key words in a text string patricia tipp Excel Discussion (Misc queries) 1 February 28th 06 05:01 PM
Alphabetically reorder a text string with multiple words Mike S Excel Worksheet Functions 4 October 28th 05 07:21 PM
Alphabetically reorder a text string with multiple words Grandslam90 Excel Worksheet Functions 1 October 28th 05 06:30 PM


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