Solved

Excel Formula add SUBSTITUTE(B1;" "."") to formula from splitting displayname

Posted on 2014-09-21
4
441 Views
Last Modified: 2014-09-21
hi,

In Cell "G2" i have this formula

=TRIM(MID(C2,FIND(",",C2,1)+1,IFERROR(FIND("(",C2,1)-FIND(",",C2,1)-1,LEN(C2)))))

C2 is:  Jones, Mike

The result in G2 is  "Mike"   Firstname

in Cell "H2" i have this formula

=MID(C2,1,(SEARCH(",",C2))-1))

The result in H2 is  "Jones"   Lastname

so far so good but how can replace spaces or - or with "." when the displayname looks like that:

Jones-ryan, Mike Michael         Result G2 should be mike.michael and H2 jones.ryan
Jones ryan, Michael Mike         Result G2 michael.mike and H2 jones.ryan
Jones, Dimitri Jack Michael      Result G2 dimitri.jack.michael and H2 jones

The last one is different
Jones, Michael Jack (12345)      Result G2 michael.jack and H2 jones.12345


I tried different formula with =SUBSTITUTE(G2;" ";"") but still not working

Could anyone assist how to solve that, please?

Any help would be greatly appreciated.
Mandy
0
Comment
Question by:Mandy_
  • 2
4 Comments
 
LVL 37

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 100 total points
ID: 40335291
For all but the last one, this should work:

=SUBSTITUTE(SUBSTITUTE(TRIM(MID(C3,FIND(",",C3,1)+1,IFERROR(FIND("(",C3,1)-FIND(",",C3,1)-1,LEN(C3))))," ","."),"-",".")

and

=SUBSTITUTE(SUBSTITUTE(MID(C3,1,(SEARCH(",",C3))-1)," ","."),"-",".")

But the 'different' one -> do the numbers belong to the last name? If so, why are they the 'first name' field?
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 400 total points
ID: 40335478
For the first name (deep breath):
=SUBSTITUTE(SUBSTITUTE(TRIM(IF(ISERROR(FIND("(",C2)),MID(C2,FIND(",",C2)+2,30),MID(C2,FIND(",",C2)+2,FIND("(",C2)-FIND(",",C2)-3))),"-",".")," ",".")

For the last name (inhale):
=SUBSTITUTE(SUBSTITUTE(TRIM(IF(ISERROR(FIND("(",C2)),LEFT(C2,FIND(",",C2)-1),LEFT(C2,FIND(",",C2)-1)&"."&MID(C2,FIND("(",C2)+1,LEN(C2)-FIND("(",C2)-1))),"-",".")," ",".")

If there are compound last names like:
Washington Carver, George (123)
the last name will be
Washington.Carver.123

Side note:  These look like data from Active Directory, but I too am confused that the number (probably representing identical name listings) is after the comma.  In our system, for example, the numbers are concatenated to the last name (ex., Ray2).


Regards,
-Glenn
0
 
LVL 2

Author Closing Comment

by:Mandy_
ID: 40335483
you both are my personal heroes. Thank you muchisimo ;-)
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40335490
You're welcome.  Looks like quite a project you've got going there.  Moving to new email servers, are we? :-)
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

832 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