Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Extract first second "word" from a Cell..

I need to extract the second "word" from a Cell.

The data comes from a database, which I do have some control over. I'm
importing into Excel so that I can create new "elements" in order to do
charts.

One column, which seems so simple, is giving me problems.

The first two words in a column will always look like this:

PM Smith asdfasdfasfasdf (where asdf... is free text.)

I want extract the "Name" and create a new column with this value. I'm
hoping to avoid creating a bunch of nested "IF" statements searching for all
possible names.

Thanks,

KSL
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Extract first second "word" from a Cell..

Extracts the Nth word

=MID(MID(MID(SUBSTITUTE(A2," ","^",A1-1),1,256),FIND("^",SUBSTITUTE(A2,"
","^",A1-1)),256),2,FIND(" ",MID(MID(SUBSTITUTE(A2,"
","^",A1-1),1,256),FIND("^",SUBSTITUTE(A2," ","^",A1-1)),256))-2)

Number of word to extract in A1
Senetnce in A2.

Mike


"Leonhardtk" wrote:

I need to extract the second "word" from a Cell.

The data comes from a database, which I do have some control over. I'm
importing into Excel so that I can create new "elements" in order to do
charts.

One column, which seems so simple, is giving me problems.

The first two words in a column will always look like this:

PM Smith asdfasdfasfasdf (where asdf... is free text.)

I want extract the "Name" and create a new column with this value. I'm
hoping to avoid creating a bunch of nested "IF" statements searching for all
possible names.

Thanks,

KSL

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Extract first second "word" from a Cell..

=MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)


"Leonhardtk" wrote:

I need to extract the second "word" from a Cell.

The data comes from a database, which I do have some control over. I'm
importing into Excel so that I can create new "elements" in order to do
charts.

One column, which seems so simple, is giving me problems.

The first two words in a column will always look like this:

PM Smith asdfasdfasfasdf (where asdf... is free text.)

I want extract the "Name" and create a new column with this value. I'm
hoping to avoid creating a bunch of nested "IF" statements searching for all
possible names.

Thanks,

KSL

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Extract first second "word" from a Cell..

Perfect. I finally figured out how/why this works...and my brain hurts!

Thanks!

KSL.

"Teethless mama" wrote:

=MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)


"Leonhardtk" wrote:

I need to extract the second "word" from a Cell.

The data comes from a database, which I do have some control over. I'm
importing into Excel so that I can create new "elements" in order to do
charts.

One column, which seems so simple, is giving me problems.

The first two words in a column will always look like this:

PM Smith asdfasdfasfasdf (where asdf... is free text.)

I want extract the "Name" and create a new column with this value. I'm
hoping to avoid creating a bunch of nested "IF" statements searching for all
possible names.

Thanks,

KSL

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Extract first second "word" from a Cell..

I need to extract the second "word" from a Cell.

=MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)


Perfect. I finally figured out how/why this works...and my brain hurts!


If you like having your brain hurt, you might find this formula
entertaining<g...

=SUBSTITUTE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1,FIND("
",A1)+1),1024),""),LEFT(A1,FIND(" ",A1)),"")

Rick



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Extract first second "word" from a Cell..

I tried it, and yes to both:

1. IT works!
2. IT Hurts! (I've no clue how this one works!

KSL.

"Rick Rothstein (MVP - VB)" wrote:

I need to extract the second "word" from a Cell.

=MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)


Perfect. I finally figured out how/why this works...and my brain hurts!


If you like having your brain hurt, you might find this formula
entertaining<g...

=SUBSTITUTE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1,FIND("
",A1)+1),1024),""),LEFT(A1,FIND(" ",A1)),"")

Rick


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Extract first second "word" from a Cell..

The inner SUBSTITUTE replaces everything after the second blank space (the
two embedded FIND functions locate where that is) with an empty string and
the second SUBSTITUTE works on the value returned from that operation (which
is nothing more than your first two words) by replacing everything to the
left of and including the first blank space with and empty string.

Rick


"Leonhardtk" wrote in message
...
I tried it, and yes to both:

1. IT works!
2. IT Hurts! (I've no clue how this one works!

KSL.

"Rick Rothstein (MVP - VB)" wrote:

I need to extract the second "word" from a Cell.

=MID(A1,FIND(" ",A1)+1,FIND(" ",A1,FIND(" ",A1)+1)-FIND(" ",A1)-1)

Perfect. I finally figured out how/why this works...and my brain
hurts!


If you like having your brain hurt, you might find this formula
entertaining<g...

=SUBSTITUTE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1,FIND("
",A1)+1),1024),""),LEFT(A1,FIND(" ",A1)),"")

Rick



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
Extract first to "works" from a Cell. Leonhardtk Excel Worksheet Functions 0 July 9th 07 01:36 PM
How to setup "marching ants" border Excel cell? OK in MS Word. NJDevil Excel Discussion (Misc queries) 3 January 31st 07 05:46 PM
Help!!! Enter "7" in a cell and Excel changes the "7" to "11" immediately!!! [email protected] Excel Discussion (Misc queries) 3 January 5th 07 02:18 PM
Why doesn't Excel "word wrap" always expand the cell fully? prettyb Excel Discussion (Misc queries) 1 February 10th 06 03:00 PM
Complex if test program possible? If "value" "value", paste "value" in another cell? jseabold Excel Discussion (Misc queries) 1 January 30th 06 10:01 PM


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