Reputation: 111
I am trying to:
but I am stuck. I can remove the last word using
=LEFT(TRIM(A1),FIND("~",SUBSTITUTE(A1," ","~",LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))-1)
I can remove the first word by
=RIGHT(A1,LEN(A1)-FIND(" ",A1))
But I can't combine them. I have looked online and found this:
=TRIM(REPLACE(SUBSTITUTE((TRIM(REPLACE(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),0*LEN(A1)+1,LEN(A1),"")))," ",REPT(" ",LEN(A1))),(1+LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1)*LEN(A1)+1,LEN(A1),""))
But it doesn't work.
Upvotes: 1
Views: 304
Reputation: 1950
Just put the ' remove the last word ' formula and use it in the ' remove the first word ' formula .
Implementation : Just replace all A1 in the ' remove the first word ' formula with ' remove the last word ' formula .
=RIGHT(LEFT(TRIM(A1),FIND("~",SUBSTITUTE(A1," ","~",LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))-1),LEN(LEFT(TRIM(A1),FIND("~",SUBSTITUTE(A1," ","~",LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))-1))-FIND(" ",LEFT(TRIM(A1),FIND("~",SUBSTITUTE(A1," ","~",LEN(TRIM(A1))-LEN(SUBSTITUTE(TRIM(A1)," ",""))))-1)))
Done.
Hope it helps.
Upvotes: 1