One way is to nest multiple searches and use an If statement(s). Use the position of the previous " " as the starting point for the subsequent search/find.
In the IF statement, if no 2nd space is found, don’t search for a 2nd name.
for example, this should return both the first and last name,
LEFT({Names},SEARCH(" “,{Names},SEARCH(” ",{Names}))-1)
I tried Mike’s formula, but it only returned the first name in both situations, so I dove in a had a play on my own. At first I tried throwing everything into a single formula, but things just got really hairy really quickly. In a case like this where extracting specific chunks of text involves referencing the same points multiple times, I decided to create helper formula fields to find those points, and then use those as pseudo-variables in the main formula.
For this, I made three helper formula fields — {Space 1}
, {Space 2}
, and {Space 3}
— using the following formulas, respectively:
FIND(" ", Names)
FIND(" ", Names, FIND(" ", Names) + 1)
FIND(" ", Names, FIND(" ", Names, FIND(" ", Names) + 1) + 1)
With that done, the main formula looks like this:
LEFT(
Names,
{Space 1} - 1
)
& IF(
{Space 2},
" & " &
MID(
Names,
{Space 2} + 1,
{Space 3} - {Space 2}
)
)
If you want, you can obviously make one massive formula, replacing the field names with their respective formulas. Your call.