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.
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)
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)
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
Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline
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.
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!
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.
Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
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;…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…