How to remove everything after the first space?

Is there a way to delete everything after the first space in the cell? What function should I use?

Posted on Aug 14, 2020 12:55 PM

Reply
Question marked as Top-ranking reply

Posted on Aug 14, 2020 1:54 PM

To extract, yes.

To remove, no, as this would require the formula containing the function to be in the cell which was to be modified—which would throw a self reference error (and the ast of entering the formula in the cell would immeditately replace everything in that cell.


To extract only the contents up to the first space from cell B2 and place the extracted value into cell C2, enter the formula shown below the table in C2:

start-position may be omitted. The default value is 1


LEFT(B2,FIND(" ",B2)-1)


To then replace the original value in B2 with the 'edited' value in C2:

Select and Copy C2.

Select B2, then go to the Edit menu and choose Paste Formula Result.


If you are doing this for an entire column of values in column B:

Fill the formula down the column to the last cell in coumn C.

Select all cells containing the formula. Copy.

Go Edit > Paste Formula results.

Delete column B.


Regards,

Barry


8 replies
Question marked as Top-ranking reply

Aug 14, 2020 1:54 PM in response to justyna227

To extract, yes.

To remove, no, as this would require the formula containing the function to be in the cell which was to be modified—which would throw a self reference error (and the ast of entering the formula in the cell would immeditately replace everything in that cell.


To extract only the contents up to the first space from cell B2 and place the extracted value into cell C2, enter the formula shown below the table in C2:

start-position may be omitted. The default value is 1


LEFT(B2,FIND(" ",B2)-1)


To then replace the original value in B2 with the 'edited' value in C2:

Select and Copy C2.

Select B2, then go to the Edit menu and choose Paste Formula Result.


If you are doing this for an entire column of values in column B:

Fill the formula down the column to the last cell in coumn C.

Select all cells containing the formula. Copy.

Go Edit > Paste Formula results.

Delete column B.


Regards,

Barry


Aug 14, 2020 1:34 PM in response to justyna227

"Delete" is a word typically reserved for data entry, like selecting all text after the first space and then hitting the delete key.


A formula that will return a string that is everything to the left of the first space (not including the space) would be:


Assuming the string (text) you are working with is in cell B2,

=IFERROR(LEFT(B2, FIND(" ",B2)−1),B2)


  • FIND(" ",B2) gives the numeric position of the first space character in the string in B2. Subtracting 1 from that and you get the length of the first "word", before the space.
  • LEFT(B2, number) gives the specified number of characters from the left side of the string
  • FIND will throw an error if it cannot find a space (i.e., there is only word, or no words, in the string). IFERROR(..., B2) will catch that error and return the entire contents of B2 instead.

Aug 15, 2020 2:05 AM in response to justyna227

Shamelessly "adopting" Badunit's ideas in another post, the new REGEX.EXTRACT function works nicely for this:


=REGEX.EXTRACT(B2,"\b\S+\b",1)


Setting the second parameter to 1 captures the first word, 2 the second word, etc. Short and sweet.


SG


(One assumes one can assert that strange verbs beginning with the same characters should be allowed too, though I can't find this one in the dictionary😀).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to remove everything after the first space?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.