I'm frequently dealing with historical lists of names that need to have the given names and the surname split into separate fields.
Sometimes the Surname is provided first, sometimes last and sometimes not at all - see below:-
Mary Jo Beth JONES
Mary SMITH
Peter William EVANS
Richard
SMITH John
The GivenNames frequently consist of 1, 2 or 3 words, and very occasionally 4-7 (such as "unnamed infant gender not known stillborn twin RAMSBOTTOM")
If I know the surname is first, I only have to run the FIND function to get the space's position, minus one, to do a LEFT function for the Surname data, and then a MID or RIGHT function to extract the GivenNames data.
If the Surname is last in the original field, I need to be able to find the last space in each original field.
Again, if all the fields had the same number of Given Names (say 3 given names and a Surname), I could run the following formula to identify the position of the last space in the column:-
=FIND(" ",A1,FIND(" ",A1,FIND(" ",A1)+1)+1)
Mary Jo Beth JONES then returns 13
As many people are not recorded with more than one Given Name, and many are recorded with more than two, how do I create a formula to count the number of spaces in a field so I can then use that figure to determine how the formula is constructed?
Example:
A B C D E F G
1 Names LEN Formula #Spaces LastSpacePlace GivenNames Surname
2 Mary Jo Beth JONES =LEN(A2) ? 3 =FIND(" ",A2,FIND(" ",A2,FIND(" ",A2)+1)+1) =LEFT(A2,E2-1) =RIGHT(A2,B2-E2)
3 Mary SMITH =LEN(A3) ? 1 =FIND(" ",A3) =LEFT(A3,E3-1) =RIGHT(A3,B3-E3)
4 Peter William EVANS =LEN(A4) ? 2 =FIND(" ",A4,FIND(" ",A4)+1) =LEFT(A4,E4-1) =RIGHT(A4,B4-E4)
5 Richard =LEN(A5) ? 0 0 =LEFT(A5,B5)
6 SMITH John =LEN(A6) ? 1 =FIND(" ",A6) =RIGHT(A6,E6-D6-1) =LEFT(A6,E6-D6)
results in:-
Names LEN Space#Formula #Spaces LastSpacePlace GivenNames Surname
Mary Jo Beth JONES 18 ? 3 13 Mary Jo Beth JONES
Mary SMITH 10 ? 1 5 Mary SMITH
Peter William EVANS 19 ? 2 14 Peter William EVANS
Richard 7 ? 0 0 Richard
SMITH John 10 ? 1 6 John SMITH
Many thanks to those who take the time to look at my question and ponder how to solve it.
Data Cruncher.![]()
Bookmarks