Thread: Error trapping
View Single Post
 
Old 12-18-2017, 11:50 PM
ArviLaanemets ArviLaanemets is offline Windows 8 Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Default

A correct format will be like:
Forename, Surname, Title
John, Smith, Mr

To determine, which part in full name belongs to where is possible only, when there are certain rules how this full name is composed, and the number of those rules is limited, as you have to include all of them into every formula.

P.e.
1 When the full name doesn't have comma in it, then 1st part is may be title with possible values Mr/Ms/Mrs;
2.a. When the full name doesn't have comma in it, then 1st part after title is forename, and the rest is surname;
or
2.b. When the full name doesn't have comma in it, then last part is surname, and the rest except title is forename;
3. Otherwise at end of full name may be title. All before comma is surname, and all after comma and space except title is forname;

When these rules are always fulfilled, you can calculate all parts of name. To keep formulas length reasonable, I advice to use helper columns which you can hide later.
Title:
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr","Mr", IF(RIGHT(FullName,3)=" Ms","Ms",IF(RIGHT(FullName,4)=" Mrs","Mrs",""))),
IF(LEFT(FullName,3)="Mr ","Mr", IF(LEFT(FullName,3)="Ms ","Ms",IF(LEFT(FullName,4)="Mrs ","Mrs",""))))
NameWithoutTitle
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr", LEFT(FullName,LEN(FullName)-3), IF(RIGHT(FullName,3)=" Ms",LEFT(FullName,LEN(FullName)-3),IF(RIGHT(FullName,4)=" Mrs", LEFT(FullName,LEN(FullName)-4),FullName))),
IF(LEFT(FullName,3)="Mr ",RIGHT(FullName,LEN(FullName)-3), IF(LEFT(FullName,3)="Ms ",RIGHT(FullName,LEN(FullName)-3),IF(LEFT(FullName,4)="Mrs ",RIGHT(FullName,LEN(FullName)-4),FullName))))
ForeName:
Code:
 
=IF(FIND(",",FullName)>0,
RIGHT(NameWithoutTitle, LEN(NameWithoutTitle)-FIND(" ", NameWithoutTitle)),
LEFT(NameWithoutTitle, FIND(" ", NameWithoutTitle) -1)
etc.

PS. You have to check formulas, as I did write them on fly.
Reply With Quote