I need a formula to separate Christian names from surnames when joined together in a name in a text cell e.g. "JohnSmith" needs to become "John Smith"

Cozkincaud

New Member
Joined
Apr 18, 2019
Messages
18
Office Version
  1. 2021
Platform
  1. Windows
HI,

I have a spreadsheet with a column of cells containing names (Christian name and surname). Sometimes there is no space between the Christian name and surname: e.g. "Richard King" appears as "RichardKing". In these cases I need to add a space between the Christian name and the surname. I imagine I could do this with a formula that:

1. finds the second capital letter in the text cell and inserts a space before it (my preferred choice)
2. finds the first string that starts with a lowercase letter that is followed by an uppercase letter and then inserts a space between them.

Unfortunately, I have not been able to find any Excel formulas that do any of the above.

(I could also remove the first capital letter; then find the first capital letter in the text string and place a space before it. I would place the first letters of the Christian names, which are all uppercase, in the cells of another column. I would then add them back to the cells holding the names once I had inserted the required space between the Christian name and the surname. This way I only have to search for the first uppercase letter. I'm assuming it is easier to find the first uppercase letter in a string cell than the nth one.

So I would be most grateful to any forum members who could devise or direct me to any Excel formula that would help me separate my joned Christian names and surnames

The string cells I am working with can contain any of the following types of joined Christian names and surnames:

1. Just one Christian name and surname not separated as in: JohnWilliams
2. Two names with one of the names not having the Christian name separated from the surname as in: RobertJones Thomas Smith
3. Two names with both of the names not having the Christian name separated from the surname as in: HenryPhillips AgnesWithers
4 Several names with some of the names not having the Christian name separated from the surname as in: William Putnam Tod Phillips Adamwalters Tim Thomas ArthurBrown

Note: 1. The first letter of the Christian name and the surname are always capitalized while the rest of the Christian name and surname are always in lower case.
2. The names themselves are always separated by a space.
 
Hello, if you are using Excel 365 and have access to REGEX functions, you maybe could e.g. try something like:

Excel Formula:
=REGEXREPLACE(A1,"(?<=[a-z])(?=[A-Z])"," ")
 
Upvote 0
Hello, if you are using Excel 365 and have access to REGEX functions, you maybe could e.g. try something like:

Excel Formula:
=REGEXREPLACE(A1,"(?<=[a-z])(?=[A-Z])"," ")
Thanks for the suggestion but I'm still using Microsoft Professional 2021 and don't have the Regex, TextBefore and TexAfter functions.
 
Upvote 0
Try:

Book1
AB
1NameWith added spaces
2John WilliamsJohn Williams
3JohnWilliamsJohn Williams
4RobertJones Thomas SmithRobert Jones Thomas Smith
5HenryPhillips AgnesWithersHenry Phillips Agnes Withers
6William Putnam Tod Phillips Adamwalters Tim Thomas ArthurBrownWilliam Putnam Tod Phillips Adamwalters Tim Thomas Arthur Brown
Sheet10
Cell Formulas
RangeFormula
B2:B6B2=LET(n,A2,s,SEQUENCE(LEN(n)),a,MID(n,s,1),CONCAT(IF(s=1,a,(IF((INDEX(a,s-1)<>" ")*((CODE(a)>=65)*(CODE(a)<=90))," "&a,a)))))


This was tested on Excel 2021. The formula basically looks for capitalized letters with no previous space, and adds the space. Note on B6 how Adamwalters was not split, since walters did not start with a capital letter.
 
Upvote 0
I'm still using Microsoft Professional 2021
I suggest that you update your forum profile (click your user name at the top right of the forum, then ‘Account details’) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,226,837
Messages
6,193,249
Members
453,784
Latest member
Chandni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top