Features of !SEMTools
↑ Навигация по задачам в Excel и возможностям надстройки !SEMTools ↑

Get the first words of Excel cells

The first word of a cell, everything before the first space, often draws the attention of anyone who works with text data. You need to treat it as a separate unit: capitalize it, put it into a separate cell, keep only it in the original cell and so on.

Besides the first word, it’s often important to get the second one, the third one and so on. And if you need to remove the first words from cells after extracting them, that’s a completely different operation with its own article.

Capitalize the first word of a cell

Capitalizing the first word is easy if there are no other characters before it. But if the cell starts with quotes, brackets, a dash or other punctuation, the solution is much more complex than just taking the first character of a cell and making it uppercase. That’s why I covered this task in a separate article: how to make the first letter in a cell uppercase.

First word into another cell – Excel formula

If the first word means the characters before the first space, the formula is quite simple:

=LEFT(A1,SEARCH(" ",A1&" ")-1)

Here A1 is the cell with the word. The SEARCH function finds the position of the first space, and the LEFT function takes everything before it.

Did you notice the extra space added to the cell value with the ampersand (&)? It’s there for cells with a single word or no words at all. Without it, SEARCH finds no space and the formula returns an error.

The convenience of a formula is that when you fill it down the column, the first words update automatically as the data in the first column changes. In Excel 365, the same is shorter with TEXTBEFORE:

=TEXTBEFORE(A1&" "," ")
The first word
B2=LEFT(A2,SEARCH(" ",A2&" ")-1)
ABC
1TextLEFT + SEARCHTEXTBEFORE (365)
2buy red sofa onlinebuy=LEFT(A2,SEARCH(" ",A2&" ")-1)buy=TEXTBEFORE(A2&" "," ")
3New YorkNew=LEFT(A3,SEARCH(" ",A3&" ")-1)New=TEXTBEFORE(A3&" "," ")
4singlesingle=LEFT(A4,SEARCH(" ",A4&" ")-1)single=TEXTBEFORE(A4&" "," ")
5=LEFT(A5,SEARCH(" ",A5&" ")-1)=TEXTBEFORE(A5&" "," ")

The space added with &" " makes both formulas work for a single word and an empty cell.

Keep only the first word in the cell

The simplest way is the built-in Find and Replace. Press Ctrl+H, type a space followed by an asterisk (“ *”) in the Find what box, and leave Replace with empty. The asterisk is a wildcard that means “any number of any characters”, so everything after the first space disappears.

Getting the first word with Find and Replace tool in Excel

Be careful: this changes all cells on the sheet unless you select a range first, and it can’t be undone after saving. The !SEMTools option is safer and works only on the selection: EXTRACT → Extract words → by position.

Get the first 2, 3 or N words

The more words you want to extract from a cell, the harder it gets. Google Sheets has the great SPLIT function, which splits a cell into words so you can take each by its index. Older Excel versions have nothing like it.

But there are alternatives. For example, to get the first two words, one option looks like this:

=IFERROR(LEFT(A1,SEARCH(UNICHAR(23456),SUBSTITUTE(A1&" "," ",UNICHAR(23456),2))-1),A1)

The formula relies on special properties of SUBSTITUTE and UNICHAR:

  • the SUBSTITUTE function can replace exactly the N-th occurrence of a substring;
  • the UNICHAR function returns a character so rare that it’s almost certainly not in the cell.

Then SEARCH finds the position of this character, and LEFT takes everything before it (1 is subtracted from the position). If the cell has fewer words than requested, there is nothing to replace, and IFERROR returns the whole cell.

It’s a good reliable formula with its pros and cons. The advantage is that it’s easy to adapt for 3, 4 or more words: just change the last argument of SUBSTITUTE, 2, to the number you need. The drawback is that UNICHAR works only in Excel 2013 and later. Here is an equivalent for older versions with the CHAR function:

=IFERROR(LEFT(A1,SEARCH(CHAR(9),SUBSTITUTE(A1&" "," ",CHAR(9),2))-1),A1)

The formula inserts a tab character, which is also very unlikely to be in the text already.

CellFirst wordFirst 2 words
Apple iPhone 15 ProAppleApple iPhone
buy running shoes onlinebuybuy running
laptoplaptoplaptop

Get the first N words with an Excel 365 formula

In Excel 365, TEXTSPLIT, SEQUENCE and TEXTJOIN make this much simpler. Replace N with the number of words:

=TEXTJOIN(" ",TRUE,INDEX(TEXTSPLIT(A1," "),SEQUENCE(N)))
  • TEXTSPLIT splits the text into separate words;
  • SEQUENCE(N) generates the numbers 1 to N;
  • INDEX takes the first N words;
  • TEXTJOIN joins them back with spaces.

An even shorter option is TEXTBEFORE with the occurrence number. IFERROR returns the whole cell if it has fewer words than N:

=IFERROR(TEXTBEFORE(A1," ",N),A1)
The first N words
B2=IFERROR(LEFT(A2,SEARCH(UNICHAR(23456),SUBSTITUTE(A2&" "," ",UNICHAR(23456),2))-1),A2)
ABCD
1TextFirst 2 (UNICHAR)First 2 (CHAR(9))First 3 (TEXTBEFORE)
2buy red sofa onlinebuy red=IFERROR(LEFT(A2,SEARCH(UNICHAR(23456),SUBSTITUTE(A2&" "," ",UNICHAR(23456),2))-1),A2)buy red=IFERROR(LEFT(A2,SEARCH(CHAR(9),SUBSTITUTE(A2&" "," ",CHAR(9),2))-1),A2)buy red sofa=IFERROR(TEXTBEFORE(A2," ",3),A2)
3New YorkNew York=IFERROR(LEFT(A3,SEARCH(UNICHAR(23456),SUBSTITUTE(A3&" "," ",UNICHAR(23456),2))-1),A3)New York=IFERROR(LEFT(A3,SEARCH(CHAR(9),SUBSTITUTE(A3&" "," ",CHAR(9),2))-1),A3)New York=IFERROR(TEXTBEFORE(A3," ",3),A3)
4singlesingle=IFERROR(LEFT(A4,SEARCH(UNICHAR(23456),SUBSTITUTE(A4&" "," ",UNICHAR(23456),2))-1),A4)single=IFERROR(LEFT(A4,SEARCH(CHAR(9),SUBSTITUTE(A4&" "," ",CHAR(9),2))-1),A4)single=IFERROR(TEXTBEFORE(A4," ",3),A4)

The 2nd space is replaced with a rare character, and LEFT takes everything before it. If a cell has fewer words than requested, IFERROR returns the whole cell. TEXTBEFORE with an instance number does the same in Excel 365.

Get the second, third or N-th word

Sometimes you need not the first N words, but one specific word, for example the second. The classic trick replaces every space with 100 spaces using REPT, takes the 100-character chunk where the word is with MID, and removes the extra spaces with TRIM. For the second word:

=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",100)),(2-1)*100+1,100))

In Excel 365, it’s simply:

=INDEX(TEXTSPLIT(A1," "),2)
The N-th word
B2=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100))
ABCD
1Text2nd word (REPT)2nd word (365)3rd word (365)
2buy red sofa onlinered=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",100)),(2-1)*100+1,100))red=INDEX(TEXTSPLIT(A2," "),2)sofa=INDEX(TEXTSPLIT(A2," "),3)
3New YorkYork=TRIM(MID(SUBSTITUTE(A3," ",REPT(" ",100)),(2-1)*100+1,100))York=INDEX(TEXTSPLIT(A3," "),2)#REF!=INDEX(TEXTSPLIT(A3," "),3)
4single=TRIM(MID(SUBSTITUTE(A4," ",REPT(" ",100)),(2-1)*100+1,100))#REF!=INDEX(TEXTSPLIT(A4," "),2)#REF!=INDEX(TEXTSPLIT(A4," "),3)

The REPT trick spreads the words 100 characters apart and takes the 2nd 100-character slice; with no 2nd word, it returns an empty string. INDEX(TEXTSPLIT(…),N) returns #REF! when there are fewer than N words — wrap it in IFERROR.

Extract first N words in 2 clicks

Knowing Excel functions helps a lot, and for enthusiasts I have a whole Excel functions reference. But building complex formulas takes time, and so does keeping a huge file with examples somewhere on your disk.

If you value your time, the procedures of my !SEMTools add-in will help. One of them takes the first N words in all selected cells and either puts them into the next column or keeps them in the original cells. A small checkbox controls the output mode. No formulas to remember, type in or fill down:

Getting first word from within cells in Excel, replacing initial values or outputting to next column

Why the first word isn’t extracted: common mistakes

  • The formula returns #VALUE!. The cell is empty or has no spaces, and the extra space after A1 was forgotten. Check that the formula contains A1&" ".
  • The first word is empty. The cell starts with a space. Remove extra spaces first or wrap A1 in TRIM.
  • Punctuation stays with the word: “Hello,” instead of “Hello”. The formula splits by spaces only. Remove punctuation first if you need clean words.

Extract the first word or the first N words from whole columns right in place or into the next column, without formulas.
!SEMTools solves this and hundreds of other text tasks in a couple of clicks!

Summary: which way to get the first words

I hope you found what you were looking for on this page and were able to get the first words from your cells. For the first word, LEFT + SEARCH is enough, for N words use the SUBSTITUTE trick or TEXTBEFORE in Excel 365. For whole columns, !SEMTools does it in a couple of clicks, no syntax required.

You may also be interested in related operations in the extract words section and in counting words in cells.

Leave a Reply

Your email address will not be published. Required fields are marked *

*