Reputation: 41
I have a weird situation I am trying to work through.
I have a list of names in different formats. All I want to do is add a period to single letters because it is a middle initial.
I have tried:
=IF(LEN(A2)=1,A2&". ",IF(A2="","",A2&" "))
This works but misses instances with '&' and another name. So in A2, the result comes out to Michael F. & Jane J instead of Michael F. & Jane J.
=SUBSTITUTE(SUBSTITUTE(TRIM(A2)," &",". &")&".","..",".")
This ran into errors in instances with a single name and no middle initial or when there are no names in the cell or when there is a fill middle name.
Any suggestions? Text to columns also works. I can split them out and then run the above formula on all four columns then concatenate but it is an inefficient process.
Thank you!
Upvotes: 0
Views: 1264
Reputation: 3802
In B2
, formula copied down :
=SUBSTITUTE(SUBSTITUTE(A2," &",". &")&".","..",".")
Edit :
If your source data have a space after the last period, try to add a trim() to remove the last space and the formula become >>
=SUBSTITUTE(SUBSTITUTE(TRIM(A2)," &",". &")&".","..",".")
Upvotes: 1