5

I want a function to return the first two names in a cell for example

"Jones, Anna Mary" will return "Jones Anna"

I tried =LEFT(A1, FIND(" ",A1)-1) but it returns only Jones.

Thanks

3 Answers 3

9

You could get everything before the 2nd space by using this version

=LEFT(A1,FIND(" ",A1,FIND(" ",A1)+1)-1)

That would still include the comma so if you don't want that you can add a SUBSTITUTE function to remove commas, i.e.

=SUBSTITUTE(LEFT(A1,FIND(" ",A1,FIND(" ",A1)+1)-1),",","")

0
1
=LEFT(SUBSTITUTE(A1," ","-",2),FIND("-",SUBSTITUTE(A1," ","-",2),1)-1)

I used the SUBSTITUTE() function to replace the second space with a hyphen. I then used the FIND() function on the SUBSTITUTE string.

1
  • It would be sufficient, though, to use just A1 as the first argument of LEFT function, i.e. =LEFT(A1,FIND("-",SUBSTITUTE(A1," ","-",2),1)-1) Aug 31, 2012 at 22:06
1

I just wanted to add another answer, that works even if some of the cells don't have two or more spaces:

=TRIM(LEFT(SUBSTITUTE(A1, " ", REPT(" ",255),2), 255))

(from mikerickson at http://www.mrexcel.com/forum/excel-questions/703900-delete-everything-after-second-space-each-cell.html)

(and, of course, if you're using a non-English system - like I am here in Sweden - you might have to replace all commas with semicolons.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.