How to Remove Special Characters in Excel

This article describes various ways to remove special characters in Excel.

Here’s an overview of the methods and formulas we’ll be applying.

Overview of removing special characters in excel using excel functions, features and VBA code


Suppose we have a dataset containing the ID and Name of some Employees. The names contain some special characters. Let’s remove them!

Sample dataset containing id number and names with special character

 

Method 1 – Using Excel Functions

We can construct a formula using functions like SUBSTITUTE, RIGHT, and LEFT to remove special characters.


1.1  – Using the SUBSTITUTE Function

The SUBSTITUTE function is used to replace one character with another.

Steps:

  • Select cell E5 and enter the following formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C5,"#",""),"!",""),"$",""),"%",""),"&","")
Formula Description:

The syntax of the formula:

=SUBSTITUTE(text, old_text, new_text, [instance_num])

  • text = the string you want to work on.
  • old_text = the text you want to remove.
  • new_text = the replaced text (in this case, a blank “”).
  • instance_name = the instance of appearance of old_text in text, in case there are several instances.

The formula of SUBSTITUTE to remove special characters in Excel

  • Press ENTER and drag the “Fill Handle” down to fill the other cells in Output.

The special characters are removed from the cells.

Final Output after removing special characters


1.2 – Combining the RIGHT, and LEN Functions

This formula removes characters from the right side of the text.

Steps:

  • Select cell E5 and enter the formula below:
=RIGHT(C5,LEN(C5)-1)

Where,

  • The LEN function provides the length of the texts.
  • The RIGHT function returns a specific number of characters in the text, counting from the right.

Formula of RIGHT, LEN functions to delete special characters

  • Press ENTER and drag the “Fill Handle” down to fill the rest of the cells in Output.

All the special characters from the right are removed.

Final result after deleting special characters from the right hand side


1.3 Using the LEFT and LEN Functions

You can similarly remove a special (or any other) character from the left of the text with the help of the LEFT and LEN functions.

Steps:

  • Select cell E5 and enter the following formula:
=LEFT(C5,LEN(C5)-2)

Where,

  • The LEN function returns the length of the string.
  • The LEFT function then removes 2 characters from the left and provides an output of #Sen.

Formula of LEFT, and LEN to erase characters from left side

  • Press ENTER  and pull the “Fill Handle” down to fill the column.

All the special characters are removed from the left.

Final result removing special characters from the left hand side


Method 2 – Using the Flash Fill Feature

The Flash Fill is the easiest way to remove special characters in Excel.

 

Sample dataset containing id number and names with special character

Steps:

  • Select cell D5 and type “Sen” (the text in cell C5 without the special characters).

Typing the name manually without special characters as preview for flash fill feature to fill other cells

  • Select cell D6.
  • Go to the Home Ribbon.
  • Click Editing >> Fill >> Flash Fill

Performing flash fill from the Home ribbon for other cells in the same column

The Excel Flash Fill feature will automatically fill the other cells in the column without special characters.

Final output after removing special characters with flash fill command


Method 3 – Using the Find & Replace Feature

Let’s erase the special characters from the Name column below, and return the “clean” names in a new column.

Sample dataset containing id number and names with special character

Steps:

  • Select cells C5:C11 and press CTRL+C to copy.

Copying data to another column with CTRL+C shortcut

  • Select cells D5:D11 and hit CTRL+V to paste.

Pasting data to another column with CTRL+V shortcut

  • Select the pasted output.
  • Use the keyboard shortcut CTRL+F to open the Find and Replace window.

Opening find and replace window with CTRL+F command

  • In the “Find what” box, enter the special characters “$&%” and leave the “Replace with” box blank.
  • Click “Replace All”.

Entering special characters in the “Find what” field and replacing them with blanks by pressing replace all button

A confirmation window will pop up confirming all the replacements.

Confirmation of replaced characters from data table

The names without the special characters are successfully extracted.

Final output with find and replace feature by deleting specific characters


Method 4 – Using the Power Query Tool

If you are using Microsoft Excel 2016 or Excel 365, the Power Query tool is pre-installed. If you are using Microsoft Excel 2010 or 2013, you can install it from the Microsoft website.

Steps:

  • Select your range of data along with the header.
  • Select From Table/Range from the Data tab.

Opening Power Query window from data tab

A “Create Table” dialog box will open.

  • Select the range of your selected data and tick My table has headers.
  • Click OK.

Confirming data table with header for power query command

A new window named Power Query Editor will open.

  • Select Custom Column from the Add Column tab.

Addition of custom column from add column option

The Custom Column box will open.

  • Enter “Output” as the New column name option (or whatever name you want).
  • Enter the formula below in the Custom column formula field:
=Text.Select([NAME],{"A".."z","0".."9"})
  • Click the OK button.

Applying formula for the newly created custom column and naming it

  • Click Close & Load from the File tab of the Power Query Editor.

Pressing close & load to save the newly added column erasing characters

You will find a new worksheet in your workbook where you will see the final result as shown here.

Final Output with texts after removing special characters using power query tool


Method 5 – Using VBA Code

In this VBA code, we will define a user-defined function to remove special characters, and then apply it.

Steps:

  • Open the worksheet and press ALT+F11 to open the “Microsoft Visual Basic for applications” window.

Pressing ALT+F11 to launch Visual Basic Application window

  • Inside the new module place the following code and click “Save”:
Function Erase_Special_Characters(Txt As String) As String
Dim xx As String
Dim yy As Long
xx = "$&%"
For yy = 1 To Len(xx)
Txt = Replace$(Txt, Mid$(xx, yy, 1), "")
Next
Erase_Special_Characters = Txt
End Function
Code Explanation:

  • We name the function Erase_Special_Characters().
  • We define the arguments Txt, xx, and yy as the String data type.
  • We use a For Next loop to cycle through our range and apply the REPLACE and MID functions to replace special characters with a space.

Applying code for a defined function to erase special characters

  • Go back to the worksheet.
  • Select cell D5 and enter the below formula:
=Erase_Special_Characters(C5)

Applying defined function to a cell to remove specific characters

  • Press ENTER and drag the “Fill Handle” down to fill the column.

All the special characters are removed from the cells.

Final output after removing characters using VBA code

Read More: How to Remove Characters from String Using VBA in Excel


Things to Remember

  • When using the Flash Fill feature to fill cells, the columns or rows to fill from/to must be adjacent to each other.
  • If you are using Microsoft Excel versions older than 2010, you might not be able to install Power Query.
  • All the methods have pros and cons, so use what is appropriate for your requirements.

Download Practice Workbook


Related Articles

<< Go Back To Excel Remove Characters | Data Cleaning in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Syeda Fahima Nazreen
Syeda Fahima Nazreen

SYEDA FAHIMA NAZREEN is an electrical & electronics engineer who loves exploring Excel and VBA programming. To her, programming is a time-saving tool for dealing with data, files, and the internet. She's skilled in Proteus, MATLAB, Multisim, AutoCAD, Jupiter Notebook, and MS Office, going beyond the basics. With a B.Sc in Electrical & Electronic Engineering from American International University, Bangladesh, she's shifted gears and now works as a content developer. In this role, she creates techy content exclusively... Read Full Bio

2 Comments
  1. Thank you for the fantastic article, Syeda. After researching your comments about why the caret “^” characters were still remaining in D7 in your example above, I realized that the range {“A”..”z”} is actually using the Basic Latin Unicode Standard character list. So, since you’ve designated the range from capital A to lowercase z, that range would include several other characters a person might want removed if all they want is A-Z, a-z, and 0-9, such as [, \, ], ^, _, and `. If you modify the Text.Select argument from {“A”..”z”, “0”..”9″} to {“A”..”Z”, “a”..”z”, “0”..”9″}, the results will truly only select capital and lowercase letters and numbers without any special characters being overlooked. Thank you, again, for publishing this!

  2. It is effective. Thank you for providing this information.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo