Remove ASCII Character #127 in Excel

Get rid of non-printable characters in Excel worksheets

The Excel CLEAN function removes most non-printable characters except for character #127. To remove character #127 in Excel, use a special formula containing the SUBSTITUTE and CHAR functions.

The information in this article applies to Excel for Microsoft 365, Excel 2019, Excel 2016, Excel 2013, and Excel for Mac.

What Is Unicode Character #127?

Unicode character #127 controls the Delete key on the keyboard. It appears as a narrow, rectangle-shaped symbol. This character can sometimes erroneously appear when you copy and paste data in Excel.

The presence of character #127 can cause several issues, including:

How to Remove Unicode Character #127

In the example Excel worksheet below, cell A2 contains four rectangle-shaped characters along with the number 10. The LEN function, which counts the number of characters in a cell, shows that cell A2 contains six characters (the two digits for the number 10 plus the four boxes for character #127). Due to the presence of character #127 in cell A2, the addition formula in cell D2 returns a #VALUE! error message.

Remove ASCII Character #127 from Data in Excel

To turn the data in cell A2 into a calculable value, set up the following SUBSTITUTE/CHAR formula in a different cell (as seen in cell A3):

=SUBSTITUTE(A2,CHAR(127),"")

The formula replaces the four #127 characters from cell A2 with nothing (represented by the empty quotation marks at the end of the formula). As a result:

  • The character count in cell E3 is reduced to two for the two digits in the number 10.
  • The addition formula in cell D3 returns the correct answer of 15 when adding the contents for cell A3 + B3 (10 + 5).

The SUBSTITUTE function handles the replacement. The CHAR function tells the formula which characters to replace.

Remove Non-Breaking Spaces From a Worksheet

Similar to non-printable characters, the non-breaking space (&nbsp) can also cause problems with calculations and formatting in a worksheet. The Unicode code number for non-breaking spaces is #160.

Non-breaking spaces are used extensively in web pages. If data is copied into Excel from a web page, non-breaking spaces may show up in a worksheet. Removing non-breaking spaces can be done using a formula that combines the SUBSTITUTE, CHAR, and TRIM functions.

Unicode vs. ASCII Characters

Each character on a computer (printable and non-printable) has a number known as its Unicode character code or value. Another older character set known as ASCII, which stands for the American Standard Code for Information Interchange, has been incorporated into the Unicode set. As a result, the first 128 characters (0 to 127) of the Unicode set are identical to the ASCII set.

Many of the first 128 Unicode characters are referred to as control characters because these are used by computer programs to control peripheral devices such as printers. These characters are not intended for use in Excel worksheets and can cause a variety of errors if present.

Was this page helpful?