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?
Is there a way to delete everything after the first space in the cell? What function should I use?
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
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
"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)
You might consider wrapping an IFERROR around the function as shown in my post. If there is a possibility that one of your cells will be empty or contain only one "word", meaning there will be no space character to find, the function will fail and give you an error triangle.
Badunit wrote:
Assing the IFERROR part is a nice touch!
Regards,
Barry
That is turning out to be a handy function. The particular assemblage of parameters has assuredly been an asset for several Numbers users in the last day, assisting them in solving their assorted problems.
Thank you
Yikes! just noticed the typo in my last reply! Surprised the filters didn't catch it.
B.
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😀).
How to remove everything after the first space?