Open In App

How to Extract the Last Word From a Cell in Excel

Last Updated : 20 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Explore how to extract the last word from a cell in Excel. Whether you’re working with text data, names, or any other content, knowing this technique can be incredibly useful. In this article, we explain how to extract the last word from a text in a cell using the Excel function.  Extracting words from a text is an important task in text processing.

Functions to Extract the Last Word from a Cell in Excel

Eg.  Suppose we have a data file with a field called “Product_Category”, which combines both product name and their respective category name with space as below.  Assume that the last word from the “Product_Category” field is a category.  We have to extract categories from the given data in column B for further analysis.

Sample Data: We use the below list of 4 Excel user-defined functions to extract the last word.

The REPT() Function

Syntax:

REPT(text, number)

Where,

  • text – character to repeat
  • number – number of times to repeat the character

Eg: REPT(“*“,10) – returns **********

The SUBSTITUTE() Function

Syntax:

SUBSTITUTE( text, old_text, new_text, [instance_number] )

Where,

  • text – the original text 
  • old_text – text need to replace
  • new_text –text replace with old text
  • [instance_number] – Optional. The number indicates the instance number of old text to replace

Eg: SUBSTITUTE(“Filo Mix”," ",REPT("*",10)) – returns Filo**********Mix

The RIGHT() Function

Syntax:

RIGHT( text, [number_of_characters] )

Where,

  • text – original text 
  • [number_of_characters] – optional. Number characters extract from the right.

Eg: RIGHT(“Filo**********Mix”) – returns *******Mix

The TRIM() Function

Syntax:

TRIM(text)

Where,

  • text – Removes leading and trailing spaces

Eg: Eg: Trim(“Mix”) – returns Mix 

How to Extract the Last Word from a Cell in MS Excel

Follow the below steps to  Extract the last word from a Cell in Excel:

Step 1: Write header “Category” in cell B1.

Step 2: Write the formula in the data category

Write the below formula to cells “B2”.  In the given data category name is not more than 10 characters.  So we used 10 in both REPT() and SUBSTITUTE().  You can use any number greater than the maximum of the last word.

=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",10)),10))

Step 3: Drag formula B2 to B14 to fill the same formula to all other cells

Conclusion

Extracting the last word from a cell in Excel can be a handy skill for data manipulation and analysis. By following the steps outlined in this guide, you’ll be able to efficiently retrieve that crucial last word from your cell contents. Remember to use dynamic formulas and functions like RIGHT, LEN, and SEARCH to achieve accurate results.

What other text-related tasks can Excel handle?

Excel can handle various text-related tasks, such as:

  • Concatenating strings (using CONCATENATE or &)
  • Splitting text (using LEFT, RIGHT, or MID)
  • Removing duplicates (using REMOVE DUPLICATES)
  • Changing case (using UPPER, LOWER, or PROPER)

How do I adapt this method for non-English words or phrases?

To adapt to non-English words or phrases, consider using functions like SEARCH or FIND with language-specific rules. Adjust the formula based on the language’s word boundaries and characters.



Next Article
Article Tags :

Similar Reads