How to Remove Line Breaks in Excel Using CHAR and CLEAN Functions

スポンサーリンク
スポンサーリンク

About CHAR and CLEAN Functions

Overview of CHAR and CLEAN

Remove Line Breaks Excel Functions/Text Manipulation

=CHAR(CodeNumber)

=CLEAN(Text)

CHAR Overview: Returns the character corresponding to the specified numeric code.

CLEAN Overview: Removes certain non-printable characters from text, including line breaks and tab characters.

  • Use CHAR(10) to represent a line feed character. To remove line breaks, combine CHAR with the SUBSTITUTE function.
  • Common CHAR code examples:
    CHAR(8) CHAR(9) CHAR(10) CHAR(32) CHAR(160)
    Backspace Tab Line Feed Space Non-breaking Space (Windows)
  • CHAR(13) represents a carriage return. Imported text may contain CHAR(13), CHAR(10), or a combination of both.
  • To remove a particular character, use the SUBSTITUTE function.
  • To insert a line break within a cell in Excel for Windows, press Alt + Enter at the desired position.
  • To display a line break generated by a formula, enable Wrap Text for the result cell.
  • The CLEAN function removes ASCII control characters with codes 0 through 31. It does not remove every non-printable Unicode character.
  • Be careful when removing control characters because they may be important separators within the original text.

When to Use CHAR

  • To identify and remove specific line break characters within a cell using SUBSTITUTE.
  • To insert line breaks into text using CHAR(10).
  • To specify characters such as tabs and spaces in text formulas.

How to Use CHAR

Suppose cell C2 contains the text "Brooklyn" and "Downtown" separated by a line break.

You can remove the line break by combining the SUBSTITUTE and CHAR functions.

  A B C D E
1 Original Text Result Formula
2 New York
Brooklyn
Downtown
BrooklynDowntown =SUBSTITUTE(C2,CHAR(10),"")
3
4
5

The text in C2 contains a line break between "Brooklyn" and "Downtown". The formula removes that line break and joins the text without adding a space.

=SUBSTITUTE(C2,CHAR(10),"")

Result: BrooklynDowntown

If you want to replace the line break with a space instead of removing it completely, use:

=SUBSTITUTE(C2,CHAR(10)," ")

Result: Brooklyn Downtown

The difference is the third argument of SUBSTITUTE:

  • "": Removes the matched character without inserting anything.
  • " ": Replaces the matched character with one ordinary space.

How to Use CLEAN

The CLEAN function removes certain non-printable control characters from text.

For example, if cell C2 contains "Brooklyn" and "Downtown" separated by a CHAR(10) line break, use:

=CLEAN(C2)

Result: BrooklynDowntown

Unlike SUBSTITUTE, which allows you to specify exactly which character to remove, CLEAN removes all characters in the ASCII control-character range from 0 through 31.

This includes common control characters such as:

  • CHAR(9): Tab
  • CHAR(10): Line feed
  • CHAR(13): Carriage return

For example:

=CLEAN("Brooklyn"&CHAR(10)&"Downtown")

Result: BrooklynDowntown

However, CLEAN does not automatically insert spaces between words when it removes line breaks or tabs.

Differences Between SUBSTITUTE and CLEAN

Function Purpose Example
SUBSTITUTE Replaces a specified character or text with another value. =SUBSTITUTE(C2,CHAR(10)," ")
CLEAN Removes ASCII control characters with codes 0–31. =CLEAN(C2)

Use SUBSTITUTE when you want to remove or replace a particular character without affecting other characters.

Use CLEAN when you want to remove several types of ASCII control characters from imported text.

Important Notes

  • CLEAN does not remove all non-printable characters: It does not remove certain Unicode control characters, including codes 127, 129, 141, 143, 144, and 157.
  • Non-breaking spaces: CLEAN and TRIM do not normally remove non-breaking spaces (Unicode 160). To remove them, use =SUBSTITUTE(A1,UNICHAR(160),"").
  • CHAR(160): On Windows, this commonly represents a non-breaking space. Since CHAR uses the character set of the operating environment, use UNICHAR(160) when you specifically need the Unicode non-breaking space character.
  • Imported line breaks: Text imported from other systems may contain carriage returns (CHAR(13)) as well as line feeds (CHAR(10)).
  • Removing both line break characters: If needed, use =SUBSTITUTE(SUBSTITUTE(A1,CHAR(13),""),CHAR(10),"") to remove both types.
  • Preserving word separation: Replacing line breaks with a space may be preferable to removing them entirely when the original text contains separate words.
  • CHAR range: The CHAR function accepts code numbers from 1 to 255. For Unicode characters beyond this range, use the UNICHAR function.

Summary

The CHAR and CLEAN functions are useful for working with line breaks and non-printable characters in Excel.

CHAR returns a character from a specified code, such as CHAR(10) for a line feed. To remove or replace that character, combine CHAR with SUBSTITUTE.

CLEAN removes ASCII control characters with codes 0 through 31, making it useful for cleaning text imported from other applications.

Use SUBSTITUTE for precise character replacement and CLEAN for removing multiple ASCII control characters. Choose the appropriate function according to which characters you want to remove and whether spaces between words should be preserved.