Frank Kabel said:
or try a non array formula
=MID(A1,FIND("^",SUBSTITUTE(A1," ","^",LEN(A1)-LEN(SUBSTITUTE(A1,
" ",""))))+1,1024) ....
I didn't put the TRIM calls in my formula just to waste cycles. They're a
precaution meant to trap stray trailing blanks. If you had followed this
sound practise, your formula would have been
=MID(TRIM(A1),FIND("^",SUBSTITUTE(TRIM(A1)," ","^",
LEN(TRIM(A1))-LEN(SUBSTITUTE(A1," ",""))))+1,1024)
[Exercise: why don't you need a TRIM call in the second LEN call?]
That'd make for 9 function calls, which is one fewer than my formula above
after counting the implicit ROW and INDIRECT calls in each Seq reference. I
can do better than that, so with the defined names N referring to 1024, Seq
referring to =ROW(INDIRECT("1:"&N)), the array formula
=MID(TRIM(X99),N+2-MATCH(" ",MID(TRIM(X99),N+1-Seq,1),0),N)
uses only 7 explicit and implicit function calls. There are times when it
makes sense to avoid array formulas, but not when it takes two more function
calls to avoid them.
Other alternatives: with Longre's MOREFUNC.XLL, =WMID(X99,-1,1); with a
regular expression udf similar to the SUBSTITUTE function (such as the Subst
udf I've posted in the past), =Subst(A1,"^.*\s(\S+)\s*$","$1"), which is
much longer than WMID, but MUCH more flexible in case such things as
multiple word last names (e.g., de la Cruz) should be accomodated but
trailing generational qualifiers (e.g., Jr.) should be excluded.