Ok, I have a column of full names that are in listed in several different formats:
lastName/firstName
lastName, firstName
firstName lastName
firstName middleInitial lastName
firstName middleName lastName
I need to create a formula that extracts lastName from each one of these formats.
I have come up with the following partial formulas:
for determining "/", which works if cell DOES contain "/"
=IF(FIND("/",D2)>0,LEFT(D2,FIND("/",D2)-1),"Rather than displaying this message, if D2 does not contain '/' this results in the dreaded #VALUE!")
for determining ",", which DOES work if cell contains ","
=IF(FIND(",",D2)>0, LEFT(D2, FIND(",",D2)-1),"if D2 does not contain ',' this results in #VALUE! and not this message")
When I attempt to embed these if statements, I only get an error rather than getting a result for "/" or "," types and still do not get anything but errors for an 'else' situation. This was my attempt:
=IF(FIND("/",D5)>0, LEFT(D5,FIND("/",D5)-1), IF(FIND(",",D5), LEFT(D5,(FIND(",",D5))-1), “This should be the close of the first imbedded ‘if’and this statement should populate if D5 does not contain '/' or ',' but instead... #value! ”)
I have additionally googled a solution for pulling lastName if lastName is only one word (it will not work for John St. Paul if I want St. Paul to populate):
IF(RIGHT(D5,LEN(D5)-FIND(" ",SUBSTITUTE(D2," "," ", LEN(D5)-LEN(SUBSTITUTE(D5," ",""))))))
I am not 100% on this, but it spend some more time staring at it I know I could understand what it's saying, but at this time, I can't get my original function to not fail before even getting this far.
So...
If someone has a good idea how to write a single formula that will combine all three of these and if anyone has a good idea about handling the rare times I will have a two-word value for lastName I would be so thankful!
Best,
Andy
Aucun commentaire:
Enregistrer un commentaire