How to Extract Text from a Cell in Excel (5 Ways)

Download the Practice Workbook


5 Ways to Extract Text from a Cell in Excel

Method 1 – Using the LEFT Function to Extract Text from a Cell

The LEFT function extracts a particular number of characters from the left of a string.

Syntax of the LEFT Function:

=LEFT(text, [num_chars])

We are going to extract the first 4 characters from the cells in column B.

dataset for extracting values

Steps:

  • Insert the following formula in Cell C5.
=LEFT(B5,4)

formula for extracting text

  • Press Enter.

result after entering the formula

  • Drag the Fill Handle over the range of cells C6:C9.

how to extract text from a cell in excel

Read More: How to Extract Text after a Specific Text in Excel


Method 2 – Using the RIGHT Function to Extract Text

The RIGHT function extracts a specific number of characters from the end of a string.

Syntax of the RIGHT Function:

=RIGHT(text,[num_chars])

We are going to extract the 4 characters from the right.

Steps:

  • Use the following formula in Cell C5.
=RIGHT(B5,4)

RIGHT function to extract text

  • Press Enter.

result after entering the formula

  • Drag the Fill Handle over the range of cells C6:C9.

drag fill handle to copy the formula


Method 3 – Using the MID Function to Extract Text from a Cell in Excel

Syntax of the MID Function:

=MID(text, start_num, num_chars)

We have some codes divided into 3 parts. We are going to extract the middle 4 characters.

dataset for MID function

Steps:

  • Insert this formula in Cell C5.
=MID(B5,6,4)

MID formula to extract text from a cell

  • Press Enter.result for MID function
  • Drag the Fill Handle over the range of cells C6:C9.how to extract text from a cell in excel

Read More: How to Extract Certain Text from a Cell in Excel VBA


Method 4 – Extract Text from a Cell Using Formulas


Example 4.1 – Extract Text Before a Particular Character

The Generic Formula:

=LEFT(text,SEARCH(char,cell)-1)

We have a dataset consisting of some codes separated by a hyphen “-”. We’ll extract the text before the hyphen.

dataset for extracting text before hyphen

Steps:

  • Use the following formula in cell C5.
=LEFT(B5,SEARCH("-",B5)-1)

formula to extract text

  • Press Enter.

result after typing the formula

  • Drag the Fill Handle over the range of cells C6:C9extracted text from every cell

Read More: Extract Text Before Character in Excel


Example 4.2 – Extract Text after a Particular Character

The Generic Formula:

=RIGHT(text,LEN(text)-SEARCH("char",text))

We want to pick the characters after the “-” character.

dataset for extracting using formula

Steps:

  • Use the following formula in Cell C5:
=RIGHT(B5,LEN(B5)-SEARCH("-",B5))

formula for extracting text

  • Press Enter.

result after entering formula

  • Drag the Fill Handle over the range of cells C6:C9.

extracted texts after using formula

Read More: Extract Text After a Character in Excel


Example 4.3 – Extract Text Between Two Specific Characters from a Cell Using the MID and SEARCH Functions

We have a dataset of the Full names of some people. We are going to extract the middle name of each person.

dataset on how to extract text from a cell in excel

Steps:

  • Use this formula in Cell C5:
=MID(B5, SEARCH(" ",B5) + 1, SEARCH(" ",B5,SEARCH(" ",B5)+1) - SEARCH(" ",B5) - 1)

enter formula for extracting from middle

  • Press Enter.

result after entering the formula to extract text from a cell

  • Drag the Fill Handle over the range of Cells C6:C9.

extracted texts from the middle

Read More: How to Extract Text Between Two Commas in Excel


Method 5 – Using Find and Replace to Pick Text from a Cell

We have a list of emails and want to extract the username and domain name.

Emails to extract text from a cell in excel

Case 5.1 – Extracting the Username from the Email

Steps:

  • Copy the Text column values and paste them on the Extracted Text column.

copy text and paste om another column to extract text from a cell

  • Select all those values.

selecting the text

  • Press Ctrl + F. You will get the Find and Replace dialog box.

find and replace to extract text from a cell

  • In the Find What box type “@*. It will select all the characters starting from the @.
  • Keep the Replace With box blank.
  • Click on Replace All.

find and replace values

  • You’ll get a notification on how many replacements were made. Click OK.
  • Close the Find and Replace box.

extracted text by find and replace dialog box


Case 5.2 – Extracting the Domain Name

Steps:

  • Follow the previous case to make a copy of the mails and open the Find and Replace dialog box.

Find and replace text

  • In the Find What box, type “*@”. It will find all the characters from the beginning along with @.
  • Keep the Replace With box blank.
  • Click on Replace All.
  • Press OK on the notification and close the dialog box.

extracted domain names from email


Extract Text in Excel: Knowledge Hub


<< Go Back to String Manipulation | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
A.N.M. Mohaimen Shanto
A.N.M. Mohaimen Shanto

A.N.M. Mohaimen Shanto, a B.Sc. in Computer Science and Engineering from Daffodil International University, boasts two years of experience as a Project Manager at Exceldemy. He authored 90+ articles and led teams as a Team Leader, meticulously reviewing over a thousand articles. Currently, he focuses on enhancing article quality. His passion lies in Excel VBA, Data Science, and SEO, where he enjoys simplifying complex ideas to facilitate learning and growth. His journey mirrors Exceldemy's dedication to excellence and... Read Full Bio

4 Comments
  1. Hi, Shanto, I researched your site but can’t figure out how to fix my nagging problem for weeks now. What is a working formula that would convert MM/DD/YY date if it meets a condition. for example: in col. A, the date is 06/01/20; col. B is either condition 1, 2 or 3 Q: what is a formula to convert Col. A date to 06/GG/20 in column 3 if it meets the condition 2 in col. B? formula if it meets condition 3 and it change to 06/EE/20? and if 1, then back to 06/01/20. I would greatly appreciate any help on this? very tough! thanks in advance.

    • Hey Max, try the following VBA code

      Sub Changing_Date_Format_Using_Condition()
      Dim i As Integer

      i = InputBox(“Enter a Number”)

      If i = 2 Then
      Range(“A1”).NumberFormat = “mm/dd/yyyy”
      ElseIf i = 10 Then
      Range(“A2”).NumberFormat = “dddd-dd-mmm-yy”
      Else
      Range(“A3”).NumberFormat = “mmm-yy”
      End If

      End Sub

      Is this your required solution? If not then explain more about it. We will help you to get the result.

  2. hi i want to delete only letter(a-z) in cell which is like below-
    205apple=205
    207dog=207
    805cat=805
    2007grape=2007

    pls help me

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo