Solved

Extract First and Last name from a string in a cell.  Hope there is a function in EXCEL to do this

Posted on 2014-09-04
8
189 Views
Last Modified: 2014-09-04
I have a string value in a cell from Active Directory.  In a recent question I was able to extract the full name from this string

CN=John Doe,CN=Users,DC=mydomain,DC=int     Using this function.  =MID(A1,4,FIND(",",A1)-4).   And it works great.  

Now I would like to extract the first name and last name, each in its own cell.  In other words, "John" in the B1cell and "Doe" in the C1 cell.  This way I can import to a database table.  Any help is greatly appreciated.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 500 total points
ID: 40304932
This will work if there are only two names (no middle names or initials):
B1: =LEFT(MID(A1,4,FIND(",",A1)-4),FIND(" ",MID(A1,4,FIND(",",A1)-4))-1)
C1: =MID(MID(A1,4,FIND(",",A1)-4),FIND(" ",MID(A1,4,FIND(",",A1)-4))+1,100)

-Glenn
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 40304933
What if the name is "John Burdon Sanderson Haldane" (a real person)?
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40304937
^Yup!  Or "John Jacob Jingleheimer Schmidt"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 500 total points
ID: 40304946
In the case of more than one name:
C1:
=MID(SUBSTITUTE(A1," ","|",LEN(LEFT(A1,FIND(",",A1)-1))-LEN(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1)," ",""))),FIND("|",SUBSTITUTE(A1," ","|",LEN(LEFT(A1,FIND(",",A1)-1))-LEN(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1)," ",""))))+1,FIND(",",SUBSTITUTE(A1," ","|",LEN(LEFT(A1,FIND(",",A1)-1))-LEN(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1)," ",""))))-FIND("|",SUBSTITUTE(A1," ","|",LEN(LEFT(A1,FIND(",",A1)-1))-LEN(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1)," ",""))))-1)

Unfortunately, won't work for suffixes like "Sr." or "Jr." or "MD"

-Glenn
0
 
LVL 4
ID: 40304948
No middle or multiple names I am aware of.  
But Good God if that happens I will kill somebody!...  Good thing I am the Active Directory person.  If it happens it would definitely be my fault. Bad enough the women who get divorced and want new email boxes AND username signons AND display name changes!  
lol,,, Now you guys are going to make me check if someone did do that!  But for now, I think I can figure out that exception to the rule.  So much appreciated.  Function works great!  and the "what if" question.
0
 
LVL 4
ID: 40304950
WOW Glenn you are brilliant.  Especially on the last post.  I will use that for C1 (Just In Case).  How you know that huge function is beyond me, but wow.  You are truly the expert!!!!...   You saved me big time!
0
 
LVL 4

Author Closing Comment

by:get-ADuser -F ($_.Name -eq "Todd")
ID: 40304952
Exceptional Expert!
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40304955
Thanks.  It looks gawdawful, but the trick is to break the function up into smaller parts.  I've attached an example workbook that shows that for future reference.

-Glenn
EE-ExtractName.xlsx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question