Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-09-21
4
Medium Priority
?
470 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 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 400 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 1600 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

916 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