View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default Extract specific text

so example would be
3-PKR11500 TGDL1 TAYLOR, GEORGE 15:00 - 23:00 x
3-SP12300 TGDS2 BLOW, JOE 23:00 - 7:00 x
So i need a formula to pull the name out by comparing it to the existing
names in the database.
The end result needs to be just their name.


If the names would always be the 3rd and 4th tokens (sequences of nonspace
characters separated by space characters), the general approach would be
something like

=MID(TRIM(A1),FIND(CHAR(127),SUBSTITUTE(TRIM(A1)," ",CHAR(127),2))+1,
FIND(CHAR(127),SUBSTITUTE(TRIM(A1)," ",CHAR(127),4))
-FIND(CHAR(127),SUBSTITUTE(TRIM(A1)," ",CHAR(127),2)))


Here is a slightly shorter formula (there, that should spur you on to find
an even shorter one<g) based on the same basic assumption that the last
name is always the third token but with the additional assumption that the
last and first names are always separated by a comma-space pair...

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

Rick