5 Ways To Remove Text After Character In Excel

Intro

Learn how to remove text after a specific character in Excel with these 5 simple methods. Master the art of text manipulation using formulas, functions, and shortcuts. Discover how to use FIND, LEN, and MID functions, as well as the Text to Columns feature and VBA macros, to extract and delete unwanted text in your Excel spreadsheets.

When working with text data in Excel, it's not uncommon to encounter unwanted characters or strings that need to be removed. One common task is to remove text after a specific character, such as a comma, space, or hyphen. In this article, we'll explore five ways to achieve this in Excel.

Method 1: Using the LEFT Function

LEFT Function in Excel

The LEFT function is a simple and effective way to remove text after a specific character. This function returns a specified number of characters from the left side of a text string. To use the LEFT function, follow these steps:

  • Select the cell where you want to display the result.
  • Type =LEFT(
  • Select the cell containing the text you want to modify.
  • Type, (comma) to separate the arguments.
  • Type the position of the character you want to keep. For example, if you want to keep the text before the first space, type 5 (assuming the space is in the 6th position).
  • Close the parentheses and press Enter.

For example, if you have the text "Hello World" in cell A1 and you want to keep only the text before the space, the formula would be:

=LEFT(A1,5)

Example

Original Text Formula Result
Hello World =LEFT(A1,5) Hello

Method 2: Using the FIND Function with the LEFT Function

FIND Function with LEFT Function in Excel

If you don't know the exact position of the character you want to keep, you can use the FIND function in combination with the LEFT function. The FIND function returns the position of a specified character within a text string. Here's how to use it:

  • Select the cell where you want to display the result.
  • Type =LEFT(
  • Select the cell containing the text you want to modify.
  • Type, (comma) to separate the arguments.
  • Type FIND( to start the FIND function.
  • Type the character you want to find within quotes (e.g., " " for a space).
  • Type, (comma) to separate the arguments.
  • Select the cell containing the text you want to modify again.
  • Close the parentheses and press Enter.

For example, if you have the text "Hello World" in cell A1 and you want to keep only the text before the space, the formula would be:

=LEFT(A1,FIND(" ",A1)-1)

Example

Original Text Formula Result
Hello World =LEFT(A1,FIND(" ",A1)-1) Hello

Method 3: Using the MID Function with the LEN Function

MID Function with LEN Function in Excel

The MID function returns a specified number of characters from a text string, starting from a specified position. When combined with the LEN function, which returns the length of a text string, you can remove text after a specific character. Here's how:

  • Select the cell where you want to display the result.
  • Type =MID(
  • Select the cell containing the text you want to modify.
  • Type, (comma) to separate the arguments.
  • Type FIND( to start the FIND function.
  • Type the character you want to find within quotes (e.g., " " for a space).
  • Type, (comma) to separate the arguments.
  • Select the cell containing the text you want to modify again.
  • Type, (comma) to separate the arguments.
  • Type LEN( to start the LEN function.
  • Select the cell containing the text you want to modify again.
  • Close the parentheses and press Enter.

For example, if you have the text "Hello World" in cell A1 and you want to keep only the text before the space, the formula would be:

=MID(A1,1,FIND(" ",A1)-1)

Example

Original Text Formula Result
Hello World =MID(A1,1,FIND(" ",A1)-1) Hello

Method 4: Using Power Query

Power Query in Excel

Power Query is a powerful data manipulation tool in Excel that can be used to remove text after a specific character. Here's how:

  • Select the cell range containing the text you want to modify.
  • Go to the "Data" tab in the ribbon.
  • Click on "From Table/Range" in the "Get & Transform Data" group.
  • In the Power Query Editor, click on "Add Column" in the "Add Column" tab.
  • Type Text.BeforeDelimiter( to start the Text.BeforeDelimiter function.
  • Select the character you want to find within quotes (e.g., " " for a space).
  • Type, (comma) to separate the arguments.
  • Select the column containing the text you want to modify.
  • Click on "OK".
  • Go back to the Excel worksheet and refresh the query.

For example, if you have the text "Hello World" in column A and you want to keep only the text before the space, the Power Query formula would be:

= Text.BeforeDelimiter([Column1]," ")

Example

Original Text Formula Result
Hello World = Text.BeforeDelimiter([Column1]," ") Hello

Method 5: Using VBA Macro

VBA Macro in Excel

VBA (Visual Basic for Applications) is a programming language used to create macros in Excel. Here's how to create a VBA macro to remove text after a specific character:

  • Press "Alt + F11" to open the VBA Editor.
  • Insert a new module by clicking "Insert" > "Module".
  • Paste the following code:
Sub RemoveTextAfterCharacter()
    Dim cell As Range
    For Each cell In Selection
        cell.Value = Left(cell.Value, InStr(cell.Value, " ") - 1)
    Next cell
End Sub
  • Replace " " with the character you want to find.
  • Save the module by clicking "File" > "Save".
  • Go back to the Excel worksheet and select the cell range containing the text you want to modify.
  • Press "Alt + F8" to open the Macro dialog box.
  • Select the macro and click "Run".

For example, if you have the text "Hello World" in column A and you want to keep only the text before the space, the VBA macro formula would be:

cell.Value = Left(cell.Value, InStr(cell.Value, " ") - 1)

Example

Original Text Formula Result
Hello World cell.Value = Left(cell.Value, InStr(cell.Value, " ") - 1) Hello

Gallery of Remove Text After Character in Excel

We hope this article has helped you learn how to remove text after a specific character in Excel. Whether you use the LEFT function, FIND function, MID function, Power Query, or VBA macro, you can easily remove unwanted text and make your data more manageable.

Jonny Richards

Love Minecraft, my world is there. At VALPO, you can save as a template and then reuse that template wherever you want.