Combining first two letters from first name and first two letters from last name
up vote
6
down vote
favorite
I have a spreadsheet of usernames.
The first and last names are in the same cell of column A.
Is there a formula that will concatenate the first two letters of the first name (first word) and the first two letters of second name (second word)?
For example John Doe, should become JoDo.
I tried
=LEFT(A1)&MID(A1,IFERROR(FIND(" ",A1),LEN(A1))+1,IFERROR(FIND(" ",SUBSTITUTE(A1," ","",1)),LEN(A1))-IFERROR(FIND(" ",A1),LEN(A1)))
but this gives me JoDoe as the result.
microsoft-excel worksheet-function microsoft-excel-2013
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
6
down vote
favorite
I have a spreadsheet of usernames.
The first and last names are in the same cell of column A.
Is there a formula that will concatenate the first two letters of the first name (first word) and the first two letters of second name (second word)?
For example John Doe, should become JoDo.
I tried
=LEFT(A1)&MID(A1,IFERROR(FIND(" ",A1),LEN(A1))+1,IFERROR(FIND(" ",SUBSTITUTE(A1," ","",1)),LEN(A1))-IFERROR(FIND(" ",A1),LEN(A1)))
but this gives me JoDoe as the result.
microsoft-excel worksheet-function microsoft-excel-2013
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
1
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago
add a comment |
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I have a spreadsheet of usernames.
The first and last names are in the same cell of column A.
Is there a formula that will concatenate the first two letters of the first name (first word) and the first two letters of second name (second word)?
For example John Doe, should become JoDo.
I tried
=LEFT(A1)&MID(A1,IFERROR(FIND(" ",A1),LEN(A1))+1,IFERROR(FIND(" ",SUBSTITUTE(A1," ","",1)),LEN(A1))-IFERROR(FIND(" ",A1),LEN(A1)))
but this gives me JoDoe as the result.
microsoft-excel worksheet-function microsoft-excel-2013
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have a spreadsheet of usernames.
The first and last names are in the same cell of column A.
Is there a formula that will concatenate the first two letters of the first name (first word) and the first two letters of second name (second word)?
For example John Doe, should become JoDo.
I tried
=LEFT(A1)&MID(A1,IFERROR(FIND(" ",A1),LEN(A1))+1,IFERROR(FIND(" ",SUBSTITUTE(A1," ","",1)),LEN(A1))-IFERROR(FIND(" ",A1),LEN(A1)))
but this gives me JoDoe as the result.
microsoft-excel worksheet-function microsoft-excel-2013
microsoft-excel worksheet-function microsoft-excel-2013
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 8 hours ago
robinCTS
3,84041527
3,84041527
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 13 hours ago
prweq
313
313
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
prweq is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
1
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago
add a comment |
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
1
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
1
1
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago
add a comment |
4 Answers
4
active
oldest
votes
up vote
12
down vote
Yes; assuming each person only has a First and Last name, and this is always separated by a space you can use the below:
=LEFT(A1,2)&MID(A1,SEARCH(" ",A1)+1,2)
I could only base this answer on those assumptions as it is all you provided.
Or if you want a space to still be included:
=LEFT(A1,2)&" "&MID(A1,SEARCH(" ",A1)+1,2)
Thank you very much for your answer.
– prweq
13 hours ago
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for usingFIND()instead ofSEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to=LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)
– robinCTS
1 hour ago
add a comment |
up vote
4
down vote
This is another way...

- A - Name
- B -
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
You could go even further and remove all those extra columns by merging them=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
add a comment |
up vote
3
down vote
And to round things out, here's a solution that will return the first two characters of the first name, and the first two characters of the last name, but also accounts for middle names.
=LEFT(A1,2)&LEFT(MID(A1,FIND("~~~~~",SUBSTITUTE(A1," ","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1)),2)

You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single~instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use§.¶is another good one.
– robinCTS
1 hour ago
add a comment |
up vote
0
down vote
First off, I'd like to say that PeterH's answer is the simplest and easiest to understand. (Although my preference is to use FIND() instead of SEARCH() - typing two less characters helps in avoiding RSI ;-) )
An alternative answer that neither uses MID(), LEFT() nor RIGHT(), but instead uses REPLACE() to remove the unwanted parts of the name is as follows:
=REPLACE(REPLACE(A1,FIND(" ",A1)+3,LEN(A1),""),3,FIND(" ",A1)-2,"")
Explanation:
The inner REPLACE() removes the characters from the third character of the last name onward, whilst the outer REPLACE() removes the characters from the third character of the first name up until the space.
Addendum 1:
The above formula can also be adapted to allow for a single middle name:
=REPLACE(REPLACE(A1,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))+3,LEN(A1),""),3,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))-2,"")
This (long-winded) version allows for any number of middle names:
=REPLACE(REPLACE(A1,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+3,LEN(A1),""),3,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-2,"")
Note that, of course, BruceWayne's answer is the simplest and easiest to understand solution that allows for any number of middle names.
Addendum 2:
All of the solutions can be adapted to cater for the case of a single name only by wrapping them within an IFERROR() function like so:
=IFERROR(solution, alternate_formula)
Note that the above is a general case formula, and it might be possible to tailor a more efficient modification to a specific solution. For example, if the requirement in the case of a single name is to join the first two letters with the last two letters, PeterH's answer can be more efficiently adapted like this:
=LEFT(A1,2)&MID(A1,IFERROR(SEARCH(" ",A1)+1,LEN(A1)-1),2)
To allow for the case of an initial instead of the first name (assuming a space or dot is not acceptable as the second character) the following can be used with any solution:
=SUBSTITUTE(SUBSTITUTE(solution, " ", single_char), ".", single_char))
Note that the single character can be either hard-coded or calculated from the name.
Finally, if you really need to cater for a single character only for the full name (!), just wrap the single-name-only formula with another IFERROR(). (Assuming, of course, that the alternate formula doesn't take care of that special case.)
Addendum 3:
Finally, finally (no, really ;-) ) to cater for multiple consecutive spaces, use TRIM(A1) instead of A1.
add a comment |
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
12
down vote
Yes; assuming each person only has a First and Last name, and this is always separated by a space you can use the below:
=LEFT(A1,2)&MID(A1,SEARCH(" ",A1)+1,2)
I could only base this answer on those assumptions as it is all you provided.
Or if you want a space to still be included:
=LEFT(A1,2)&" "&MID(A1,SEARCH(" ",A1)+1,2)
Thank you very much for your answer.
– prweq
13 hours ago
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for usingFIND()instead ofSEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to=LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)
– robinCTS
1 hour ago
add a comment |
up vote
12
down vote
Yes; assuming each person only has a First and Last name, and this is always separated by a space you can use the below:
=LEFT(A1,2)&MID(A1,SEARCH(" ",A1)+1,2)
I could only base this answer on those assumptions as it is all you provided.
Or if you want a space to still be included:
=LEFT(A1,2)&" "&MID(A1,SEARCH(" ",A1)+1,2)
Thank you very much for your answer.
– prweq
13 hours ago
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for usingFIND()instead ofSEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to=LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)
– robinCTS
1 hour ago
add a comment |
up vote
12
down vote
up vote
12
down vote
Yes; assuming each person only has a First and Last name, and this is always separated by a space you can use the below:
=LEFT(A1,2)&MID(A1,SEARCH(" ",A1)+1,2)
I could only base this answer on those assumptions as it is all you provided.
Or if you want a space to still be included:
=LEFT(A1,2)&" "&MID(A1,SEARCH(" ",A1)+1,2)
Yes; assuming each person only has a First and Last name, and this is always separated by a space you can use the below:
=LEFT(A1,2)&MID(A1,SEARCH(" ",A1)+1,2)
I could only base this answer on those assumptions as it is all you provided.
Or if you want a space to still be included:
=LEFT(A1,2)&" "&MID(A1,SEARCH(" ",A1)+1,2)
answered 13 hours ago
PeterH
3,29632246
3,29632246
Thank you very much for your answer.
– prweq
13 hours ago
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for usingFIND()instead ofSEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to=LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)
– robinCTS
1 hour ago
add a comment |
Thank you very much for your answer.
– prweq
13 hours ago
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for usingFIND()instead ofSEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to=LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)
– robinCTS
1 hour ago
Thank you very much for your answer.
– prweq
13 hours ago
Thank you very much for your answer.
– prweq
13 hours ago
1
1
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
@prweq no probs, accept it as correct if it works for you
– PeterH
13 hours ago
Simplest and easiest to understand solution. (Well, except for using
FIND() instead of SEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to =LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)– robinCTS
1 hour ago
Simplest and easiest to understand solution. (Well, except for using
FIND() instead of SEARCH();-) ) Since you are assuming there is always a space separator, your second formula can be simplified to =LEFT(A1,2)&MID(A1,SEARCH(" ",A1),3)– robinCTS
1 hour ago
add a comment |
up vote
4
down vote
This is another way...

- A - Name
- B -
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
You could go even further and remove all those extra columns by merging them=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
add a comment |
up vote
4
down vote
This is another way...

- A - Name
- B -
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
You could go even further and remove all those extra columns by merging them=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
add a comment |
up vote
4
down vote
up vote
4
down vote
This is another way...

- A - Name
- B -
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
This is another way...

- A - Name
- B -
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
edited 1 hour ago
robinCTS
3,84041527
3,84041527
answered 13 hours ago
Stese
762414
762414
You could go even further and remove all those extra columns by merging them=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
add a comment |
You could go even further and remove all those extra columns by merging them=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))
– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
You could go even further and remove all those extra columns by merging them
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))– PeterH
13 hours ago
You could go even further and remove all those extra columns by merging them
=CONCATENATE(LEFT(A1,2),LEFT(RIGHT(A1,(LEN(A1)-FIND(" ",A1))),2))– PeterH
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
Yeah, I did that a few moments after!
– Stese
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
yeah I noticed you edited the answer, Nice Answer !
– PeterH
13 hours ago
add a comment |
up vote
3
down vote
And to round things out, here's a solution that will return the first two characters of the first name, and the first two characters of the last name, but also accounts for middle names.
=LEFT(A1,2)&LEFT(MID(A1,FIND("~~~~~",SUBSTITUTE(A1," ","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1)),2)

You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single~instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use§.¶is another good one.
– robinCTS
1 hour ago
add a comment |
up vote
3
down vote
And to round things out, here's a solution that will return the first two characters of the first name, and the first two characters of the last name, but also accounts for middle names.
=LEFT(A1,2)&LEFT(MID(A1,FIND("~~~~~",SUBSTITUTE(A1," ","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1)),2)

You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single~instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use§.¶is another good one.
– robinCTS
1 hour ago
add a comment |
up vote
3
down vote
up vote
3
down vote
And to round things out, here's a solution that will return the first two characters of the first name, and the first two characters of the last name, but also accounts for middle names.
=LEFT(A1,2)&LEFT(MID(A1,FIND("~~~~~",SUBSTITUTE(A1," ","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1)),2)

And to round things out, here's a solution that will return the first two characters of the first name, and the first two characters of the last name, but also accounts for middle names.
=LEFT(A1,2)&LEFT(MID(A1,FIND("~~~~~",SUBSTITUTE(A1," ","~~~~~",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1)),2)

answered 8 hours ago
BruceWayne
1,4721718
1,4721718
You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single~instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use§.¶is another good one.
– robinCTS
1 hour ago
add a comment |
You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single~instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use§.¶is another good one.
– robinCTS
1 hour ago
You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single
~ instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use §. ¶ is another good one.– robinCTS
1 hour ago
You beat me to it ;-) (It was well past midnight and I need to sleep - was planning on adding this to my answer afterwards.) A slight improvement to your formula would be to use a single
~ instead of four. If you are concerned that a Tilda might be used as part of a name (!) or, more likely, been accidentally typed, just use a character that doesn't appear on any keyboard. I prefer to use §. ¶ is another good one.– robinCTS
1 hour ago
add a comment |
up vote
0
down vote
First off, I'd like to say that PeterH's answer is the simplest and easiest to understand. (Although my preference is to use FIND() instead of SEARCH() - typing two less characters helps in avoiding RSI ;-) )
An alternative answer that neither uses MID(), LEFT() nor RIGHT(), but instead uses REPLACE() to remove the unwanted parts of the name is as follows:
=REPLACE(REPLACE(A1,FIND(" ",A1)+3,LEN(A1),""),3,FIND(" ",A1)-2,"")
Explanation:
The inner REPLACE() removes the characters from the third character of the last name onward, whilst the outer REPLACE() removes the characters from the third character of the first name up until the space.
Addendum 1:
The above formula can also be adapted to allow for a single middle name:
=REPLACE(REPLACE(A1,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))+3,LEN(A1),""),3,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))-2,"")
This (long-winded) version allows for any number of middle names:
=REPLACE(REPLACE(A1,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+3,LEN(A1),""),3,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-2,"")
Note that, of course, BruceWayne's answer is the simplest and easiest to understand solution that allows for any number of middle names.
Addendum 2:
All of the solutions can be adapted to cater for the case of a single name only by wrapping them within an IFERROR() function like so:
=IFERROR(solution, alternate_formula)
Note that the above is a general case formula, and it might be possible to tailor a more efficient modification to a specific solution. For example, if the requirement in the case of a single name is to join the first two letters with the last two letters, PeterH's answer can be more efficiently adapted like this:
=LEFT(A1,2)&MID(A1,IFERROR(SEARCH(" ",A1)+1,LEN(A1)-1),2)
To allow for the case of an initial instead of the first name (assuming a space or dot is not acceptable as the second character) the following can be used with any solution:
=SUBSTITUTE(SUBSTITUTE(solution, " ", single_char), ".", single_char))
Note that the single character can be either hard-coded or calculated from the name.
Finally, if you really need to cater for a single character only for the full name (!), just wrap the single-name-only formula with another IFERROR(). (Assuming, of course, that the alternate formula doesn't take care of that special case.)
Addendum 3:
Finally, finally (no, really ;-) ) to cater for multiple consecutive spaces, use TRIM(A1) instead of A1.
add a comment |
up vote
0
down vote
First off, I'd like to say that PeterH's answer is the simplest and easiest to understand. (Although my preference is to use FIND() instead of SEARCH() - typing two less characters helps in avoiding RSI ;-) )
An alternative answer that neither uses MID(), LEFT() nor RIGHT(), but instead uses REPLACE() to remove the unwanted parts of the name is as follows:
=REPLACE(REPLACE(A1,FIND(" ",A1)+3,LEN(A1),""),3,FIND(" ",A1)-2,"")
Explanation:
The inner REPLACE() removes the characters from the third character of the last name onward, whilst the outer REPLACE() removes the characters from the third character of the first name up until the space.
Addendum 1:
The above formula can also be adapted to allow for a single middle name:
=REPLACE(REPLACE(A1,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))+3,LEN(A1),""),3,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))-2,"")
This (long-winded) version allows for any number of middle names:
=REPLACE(REPLACE(A1,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+3,LEN(A1),""),3,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-2,"")
Note that, of course, BruceWayne's answer is the simplest and easiest to understand solution that allows for any number of middle names.
Addendum 2:
All of the solutions can be adapted to cater for the case of a single name only by wrapping them within an IFERROR() function like so:
=IFERROR(solution, alternate_formula)
Note that the above is a general case formula, and it might be possible to tailor a more efficient modification to a specific solution. For example, if the requirement in the case of a single name is to join the first two letters with the last two letters, PeterH's answer can be more efficiently adapted like this:
=LEFT(A1,2)&MID(A1,IFERROR(SEARCH(" ",A1)+1,LEN(A1)-1),2)
To allow for the case of an initial instead of the first name (assuming a space or dot is not acceptable as the second character) the following can be used with any solution:
=SUBSTITUTE(SUBSTITUTE(solution, " ", single_char), ".", single_char))
Note that the single character can be either hard-coded or calculated from the name.
Finally, if you really need to cater for a single character only for the full name (!), just wrap the single-name-only formula with another IFERROR(). (Assuming, of course, that the alternate formula doesn't take care of that special case.)
Addendum 3:
Finally, finally (no, really ;-) ) to cater for multiple consecutive spaces, use TRIM(A1) instead of A1.
add a comment |
up vote
0
down vote
up vote
0
down vote
First off, I'd like to say that PeterH's answer is the simplest and easiest to understand. (Although my preference is to use FIND() instead of SEARCH() - typing two less characters helps in avoiding RSI ;-) )
An alternative answer that neither uses MID(), LEFT() nor RIGHT(), but instead uses REPLACE() to remove the unwanted parts of the name is as follows:
=REPLACE(REPLACE(A1,FIND(" ",A1)+3,LEN(A1),""),3,FIND(" ",A1)-2,"")
Explanation:
The inner REPLACE() removes the characters from the third character of the last name onward, whilst the outer REPLACE() removes the characters from the third character of the first name up until the space.
Addendum 1:
The above formula can also be adapted to allow for a single middle name:
=REPLACE(REPLACE(A1,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))+3,LEN(A1),""),3,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))-2,"")
This (long-winded) version allows for any number of middle names:
=REPLACE(REPLACE(A1,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+3,LEN(A1),""),3,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-2,"")
Note that, of course, BruceWayne's answer is the simplest and easiest to understand solution that allows for any number of middle names.
Addendum 2:
All of the solutions can be adapted to cater for the case of a single name only by wrapping them within an IFERROR() function like so:
=IFERROR(solution, alternate_formula)
Note that the above is a general case formula, and it might be possible to tailor a more efficient modification to a specific solution. For example, if the requirement in the case of a single name is to join the first two letters with the last two letters, PeterH's answer can be more efficiently adapted like this:
=LEFT(A1,2)&MID(A1,IFERROR(SEARCH(" ",A1)+1,LEN(A1)-1),2)
To allow for the case of an initial instead of the first name (assuming a space or dot is not acceptable as the second character) the following can be used with any solution:
=SUBSTITUTE(SUBSTITUTE(solution, " ", single_char), ".", single_char))
Note that the single character can be either hard-coded or calculated from the name.
Finally, if you really need to cater for a single character only for the full name (!), just wrap the single-name-only formula with another IFERROR(). (Assuming, of course, that the alternate formula doesn't take care of that special case.)
Addendum 3:
Finally, finally (no, really ;-) ) to cater for multiple consecutive spaces, use TRIM(A1) instead of A1.
First off, I'd like to say that PeterH's answer is the simplest and easiest to understand. (Although my preference is to use FIND() instead of SEARCH() - typing two less characters helps in avoiding RSI ;-) )
An alternative answer that neither uses MID(), LEFT() nor RIGHT(), but instead uses REPLACE() to remove the unwanted parts of the name is as follows:
=REPLACE(REPLACE(A1,FIND(" ",A1)+3,LEN(A1),""),3,FIND(" ",A1)-2,"")
Explanation:
The inner REPLACE() removes the characters from the third character of the last name onward, whilst the outer REPLACE() removes the characters from the third character of the first name up until the space.
Addendum 1:
The above formula can also be adapted to allow for a single middle name:
=REPLACE(REPLACE(A1,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))+3,LEN(A1),""),3,IFERROR(FIND(" ",A1,FIND(" ",A1)+1),FIND(" ",A1))-2,"")
This (long-winded) version allows for any number of middle names:
=REPLACE(REPLACE(A1,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+3,LEN(A1),""),3,FIND("§",SUBSTITUTE(A1," ","§",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))-2,"")
Note that, of course, BruceWayne's answer is the simplest and easiest to understand solution that allows for any number of middle names.
Addendum 2:
All of the solutions can be adapted to cater for the case of a single name only by wrapping them within an IFERROR() function like so:
=IFERROR(solution, alternate_formula)
Note that the above is a general case formula, and it might be possible to tailor a more efficient modification to a specific solution. For example, if the requirement in the case of a single name is to join the first two letters with the last two letters, PeterH's answer can be more efficiently adapted like this:
=LEFT(A1,2)&MID(A1,IFERROR(SEARCH(" ",A1)+1,LEN(A1)-1),2)
To allow for the case of an initial instead of the first name (assuming a space or dot is not acceptable as the second character) the following can be used with any solution:
=SUBSTITUTE(SUBSTITUTE(solution, " ", single_char), ".", single_char))
Note that the single character can be either hard-coded or calculated from the name.
Finally, if you really need to cater for a single character only for the full name (!), just wrap the single-name-only formula with another IFERROR(). (Assuming, of course, that the alternate formula doesn't take care of that special case.)
Addendum 3:
Finally, finally (no, really ;-) ) to cater for multiple consecutive spaces, use TRIM(A1) instead of A1.
edited 1 hour ago
answered 8 hours ago
robinCTS
3,84041527
3,84041527
add a comment |
add a comment |
prweq is a new contributor. Be nice, and check out our Code of Conduct.
prweq is a new contributor. Be nice, and check out our Code of Conduct.
prweq is a new contributor. Be nice, and check out our Code of Conduct.
prweq is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1382305%2fcombining-first-two-letters-from-first-name-and-first-two-letters-from-last-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Tetsujin OP has now included their attempt to solve the issue.
– PeterH
13 hours ago
1
@PeterH - cool. vote retracted.
– Tetsujin
13 hours ago