Can Excel do nested IF Statements if something is true, and something else if the first IF statement is false?
For instance, in plain english,
If the cell contains "(" Then have it display as "X" if Cell contains ", ", or as "Y" if Cell Contains "," (no space)
If cell doesn't contain "(" Then have it display as "Z"
For instance Lets say A1 contains either "Jones, Rick S (NonEmp)" , "Jones,Rick S (NonEmp), or as "Jones, Rick S"
Then:
X = Rick S Jones (NonEmp)
Y = Rick S Jones (NonEmp)
Z = Rick S Jones
Basically I want to take the Name flip it, remove the comma, and append what is in the parenthesis to the end of the string.
I started another thread which solved some problems, but it was starting to get confusing, so I figured since this is a somewhat different issue I should start a new thread.
Here is my code.
=TRIM(IF(COUNTIF(A1,"*(*"),IF(COUNTIF(A1,"*, *"),MID(A1,FIND(", ",A1)+2,LEN(A1)-FIND("(",A1)+3)&" "&LEFT(A1,FIND(",",A1)-1)&RIGHT(A1,LEN(A1)-FIND(" (",A1)+1),IF(COUNTIF(A1,"*,*"),MID(A1,FIND(", ",A1)+1,LEN(A1)-FIND("(",A1)+3)&" "&LEFT(A1,FIND(",",A1)-1)&RIGHT(A1,LEN(A1)-FIND(" (",A1)+1),MID(A1&" "&A1,FIND(", ",A1)+1,LEN(A1))))))
This code works if A1 contains either "Jones, Rick S (NonEmp)" or "Jones, Rick S"
It will not work with "Jones,Rick S (NonEmp)" or if there is no space between the Middle initial and "(".
I want it to function like this basically...
Pseudocode:
If (Condition1 (Parenthesis in the string i.e. "Jones, Jack L (NonEmp)") = True) then
if (Condition2 (Space after Comma i.e. "Jones, Jack R (NonEmp") = True) then
if (Condition4 (Space between Middle initial & First Parenthesis i.e. "Jones, Jack L (NonEmp)")
Display as Jack L Jones (NonEmp)
elseif (Condition5 (No Space between middle initial & First Parenthesis i.e. "Jones, Jack L(NonEmp)")
Display as Jack L Jones (NonEmp)
elseif (Condition3 (No Space after Comma separating Last and first name i.e. ("Jones,Jack L (NonEmp") = True) then
if (Condition4 (Space between Middle initial & First Parenthesis i.e. ("Jones,Jack L (NonEmp"))
Display as Jack L Jones (NonEmp)
elseif (Condition5 (No Space between middle initial & First Parenthesis i.e. ("Jones,Jack L(NonEmp"))
Display as Jack L Jones (NonEmp)
endif
elseif (Condition1 = False (meaning no Parenthesis to worry about, i.e. Jones, Jack R) Then
if (Condition2 (Space after Comma i.e. "Jones, Jack L") = True) then
Display Name as Jack L Jones
elseif (Condition3 (No Space after Comma separating Last and first name i.e. ("Jones,Jack L") = True) then
Display Name as "Jack L Jones"
endif
endif
if that is too complicated, I at least want to account for spaces after the comma and no spaces after if possible.
Also I don't need help with getting it to display properly, only with the IF functions and getting them to process correctly, which allows the functions to know how to alter the string to display it uniformly.
Bookmarks