View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Greg Lovern Greg Lovern is offline
external usenet poster
 
Posts: 224
Default Text Separation Function

Hi Kate,

Assuming your data looks like this:

John Smith
John Eric Smith
John Smith (Seattle)
John Eric Smith (Boston)


I would set up some intermediary columns:
(I'm starting at row 2, assumeing headers in row 1)

Column B:
Word Count
=itCOUNTINCELL(A2," ")+1

Column C:
Has Location
=IF(RIGHT(A2,1)=")",TRUE,FALSE)

Column D:
Has Middle
=IF(OR(AND(B2=3,NOT(C2)),B2=4),TRUE,FALSE)

Column E:
Last Word
=IF(OR(AND(B2=2,NOT(C2)),AND(B2=3,C2)),2,3)

Column F:
Loc Word
=IF(C2,B2,FALSE)


Then use those to split out the First, Middle, Last, and Location:


Column H:
First Name
=itGETWORD(A2,1)

Column I:
Middle Name
=IF(D2,itGETWORD(A2,2),"")

Column J:
Last Name
=itGETWORD(A2,E2)

Column K:
Location
=itEXCLUDE(itGETWORD(A2,F2,,,," "),"(",")")


To get itCOUNTINCELL, itGETWORD, and itEXCLUDE, you'll need to
download and install the Free Edition of inspector text:
(it never expires)

http://precisioncalc.com/it


For more information on each of those three functions:

itCOUNTINCELL
http://precisioncalc.com/it/itCOUNTINCELL.html

itGETWORD
http://precisioncalc.com/it/itGETWORD.html

itEXCLUDE
http://precisioncalc.com/it/itEXCLUDE.html


Good luck with your project!


Greg Lovern

http://PrecisionCalc.com
More Power In Excel



On May 15, 4:44*pm, kateconrey
wrote:
I have a database with one column of information including names (First Last,
or First Middle Last) and for some names, locations in parenthesis. *I am
looking for a function that will allow me to split these pieces into separate
columns for First Name, Middle Name (where applicable), Last Name, and
Location (where listed). *Does this exist?