
Today I had a list of full names (eg “Ed Smith”) in a Numbers spreadsheet. I wanted to separate it into first and last name to be able to sort if alphabetically. It was harder than it should be – in my opinion Apple should have a firstname and lastname function! But they don’t. So here’s how to get first name and last name.
After you’ve done this if you want to delete the original full names you’ll need to ‘copy’ then ‘paste values’ over the formula.
The Original full name is in the cell ‘B2’
Firstname:
=LEFT(B2,(SEARCH(" ",B2)-1))
Lastname:
=MID(B2,(SEARCH(" ",B2)+1),20)
Explanation
The LEFT function takes the first digits of the cell, up until a certain point.
The SEARCH function looks for a space ” “.
So the Firstname function I made above is just taking all the letters up until the first space. It needs a ‘-1’ in the formula or else it would take the space as well.
The MID function grabs all the letters from a certain point on.
So this takes the next 20 letters after the space. (The +1 means start after the space).
Update: Middlename
OK, in reply to a question below, which I took as a challenge, here’s how to extract a middle name:
MID(B2,(SEARCH(" ",B2)+1),(((SEARCH(" ",B2,(SEARCH(" ",B2,1)+1)))−(SEARCH(" ",B2,1)+1))))
And here is a better way to get ‘lastname’ if you have a list of names that may have an initial or a middle name.
RIGHT(B2,(SEARCH(" ",B2)))
This helped tremendously. Thank you!
Thank you. This formula for separating first and last names on an Apple Spreadsheet Page worked fast and easy. Thanks for sharing.
You know that the “better way” to extract the last name doesn’t work at all, right?
RIGHT(B2,(SEARCH(” “,B2)))
This search finds the position of the FIRST space when counting from the LEFT. You need to take the length of the whole string and subtract the found position, then you can use that number to extract from the right.
This ONLY works, though, when the name has just two parts (because, again, the search starts from the LEFT and finds the first word break) – middle names, titles, multiple non-hyphenated surnames, or ordinals at the end will still mess it up.
I see what you mean!
PS: I found the solution that works: :-D
=RIGHT(FullName,
LEN(FullName)−SEARCH(“#”,
SUBSTITUTE(FullName,” “,”#”,
LEN(FullName)−LEN(SUBSTITUTE(FullName,” “,””)))))
What it does is first subtract from the length of the original FullName the length of the substituted FullName where all spaces were removed. This tells you how many word breaks there are (or at least number of spaces, in case you have some double-spaced breaks – but it works for this purpose regardless).
With that count you throw that right back into a substitute on the FullName to change the last space into a “#” (use whatever tagging character works for your data). Now you have a marker for the last word.
Using search you can find the position of the “#”, which when again subtracted from the original FullName’s length gives you the size of the last word, so that you can finally bite that many characters into the FullName from the right.
Enjoy!
Good work – what a formula!!!
It worked! Thank you
WOW I have to say THANK YOU this was so so helpful.
Thank you so much!!!
Thanks, but when I try to delete the original full name column it puts those triangles with the exclamation mark in new columns. I guess the new columns are pulling from the original? How do I get rid of original without messing up the new? Make sense?
You need to ‘copy’ then ‘paste values’ so it pastes the results not the formula.
My spreadsheet has several rows. How do I apply the equation for the entire column?
There is a much easier way to do this now!!!
First you can use the Find and replace tool (Command+F)
In the Find section put the space or comma (whatever is separating the names)
In the Replace section replace it with ,SPACE just use the space key don’t type the word SPACE
Click replace all.
Copy the entire column and paste it into a Text editor like Text Edit and save the text document.
Open the text document in numbers and when you do a prompt opens at the top of your document asking if you want to adjust the import settings. Click on Adjust Settings.
Make sure that it is set to “Delimitedâ€
Choose ,(comma) as your delimiter
This should separate the names.
A good resource for this is in this video.
https://macmost.com/numbers-text-import-options.html
No matter what I try, I get a red triangle with exclamation mark saying “The formula contains a syntax error”.
There is a much easier way to do this now!!!
First you can use the Find and replace tool (Command+F)
In the Find section put the space or comma (whatever is separating the names)
In the Replace section replace it with ,SPACE just use the space key don’t type the word SPACE
Click replace all.
Copy the entire column and paste it into a Text editor like Text Edit and save the text document.
Open the text document in numbers and when you do a prompt opens at the top of your document asking if you want to adjust the import settings. Click on Adjust Settings.
Make sure that it is set to “Delimited”
Choose ,(comma) as your delimiter
This should separate the names.
A good resource for this is in this video.
https://macmost.com/numbers-text-import-options.html
THIS is it!!!!
Brilliant.
I have followed these steps, but can’t get Numbers to open the TextEdit file. It is grayed out. What am I doing wrong?
Awesome. Thank you. Make sure to convert the text edit file to “Plain text” before saving or you cannot open the document in numbers.
You are a Ninja! Thank you for such an easy fix to 2,500 names on a spreadsheet that I received for Leads….
Original formula worked like a charm. Thanks!
Hey ty! Totally worked.
FIX FOR FORMULA /TEST ISSUE, just open NOTES, like apple Notes app and start one cell of a table. Then copy and paste the first name column, then last name column. It will show as text values. Copy from Notes and paste back in Numbers and it will be text, not formulas