Excel Formula to Remove Everything After the First Space

OilEconomist

Active Member
Joined
Dec 26, 2016
Messages
439
Office Version
  1. 2019
Platform
  1. Windows
Thanks in advance and I will give feedback on whether it works or not.

I have cell entries with more than one word and I would like to extract only the first word. For example

First Word Only = First

I tried to use
Code:
=LEFT(A2, FIND( "^^", SUBSTITUTE( A2," ","^^",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))))-1)

But it would give me everything except after the first space. The formula gave me "First Word"
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi OilEconomist,

Try =SUBSTITUTE(A1,IFERROR(MID(A1,SEARCH(" ",A1),999),1),"")

The IFERROR is there so if there's only one word (like my example "Doggy" then you still get it returned.

Book1
AB
1First word onlyFirst
2DoggyDoggy
3When the saints go marching inWhen
4Cats and dogs and rock and rollCats
Sheet1
Cell Formulas
RangeFormula
B1:B4B1=SUBSTITUTE(A1,IFERROR(MID(A1,SEARCH(" ",A1),999),1),"")
 
Upvote 0
Maybe
Rich (BB code):
=LEFT(A1,FIND(" ",A1,1))
 
Upvote 0
With error trapping
Rich (BB code):
=IFERROR(LEFT(A1,FIND(" ",A1,1)),A1)
 
Upvote 0
Toadstool
Michael M
DanteAmor

Thank you so much. I'm testing, but I think something is wrong with my data. I'm trying to use it to obtain the first word on hyperlinks. I have not tested all of you guyz recommended formulas, but I will. I just wanted to get back to everyone and say thank you so much!
 
Upvote 0
You mean you trying to extract the first word from a hyperlink ??
That is a lot different from extracting from simple text !!
What defines the first word in the hyperlinks, as most hyperlinks I've dealt with are basically one word seperated by characters like underscores.
Can you post some examples ??
 
Upvote 0
Here is an alternative solution using Power Query. Mcode follows
VBA Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1.1", type text}, {"Column1.2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Column1.2"})
in
    #"Removed Columns"
 
Upvote 0
Maybe this then
Rich (BB code):
=LEFT(TEXT(A1,"0"),FIND(" ",A1,1))
 
Upvote 0
You mean you trying to extract the first word from a hyperlink ??
That is a lot different from extracting from simple text !!
What defines the first word in the hyperlinks, as most hyperlinks I've dealt with are basically one word seperated by characters like underscores.
Can you post some examples ??
Sorry for not responding sooner. Will test this weekend and get back to you.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top