Skip to content
xlsoffice. All Rights Reserved
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Lookup and Reference Examples

  • CHOOSE function: Description, Usage, Syntax, Examples and Explanation
  • How to get address of first cell in range in Excel
  • How to get first column number in range in Excel
  • Find closest match in Excel
  • Count rows with at least n matching values

Data Analysis Examples

  • How to perform a t-Test in Excel
  • Randomize/ Shuffle List in Excel
  • How To Load Analysis ToolPak in Excel
  • How to conditionally sum numeric data in an Excel table using SUMIFS
  • How to create Gauge Chart in Excel

Data Validation Examples

  • Excel Data validation must contain specific text
  • Excel Data validation number multiple 100
  • Excel Data validation allow weekday only
  • Excel Data validation no punctuation
  • Excel Data validation don’t exceed total

Remove line breaks in a cell in Excel

by

To remove line breaks from a cell, or from text inside a formula, you can use a formula based on the SUBSTITUTE and CHAR functions.

Formula

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

Explanation

In the example shown, the formula in C5 is:

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

which replaces line breaks in B5 with commas.

How this formula works

First, you should know that Excel contains two functions, CLEAN and TRIM, that can automatically remove line breaks and extra spaces from text. For example to strip all line breaks from a cell, you could use:

=CLEAN(B5)

In this case, however, we are removing line breaks and replacing them with commas, so we are using the SUBSTITUTE function instead of CLEAN. SUBSTITUTE can locate matching text anywhere in a cell, and replace it with the text of your choice. SUBSTITUTE can accept up to four arguments, but we are using only the first three like this:

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

The text comes from cell B5.

Worked Example:   Convert feet and inches to inches in Excel

The “old text” is entered as CHAR(10). This will match the line break character used in Windows.

Worked Example:   How to split text with delimiter in Excel

The “new text” is entered as “, “. This translates to a comma plus one space. We need the quotes because this is a text value.

Worked Example:   Get workbook name and path without sheet in Excel

SUBSTITUTE then replaces all line breaks in the cell with commas and returns the final result as text in C5. Because “old text” is an argument, you can change the comma to any other text you like.

Post navigation

Previous Post:

Remove first character in a cell in Excel

Next Post:

Remove text by matching in a cell in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others
  • CHAR function: Description, Usage, Syntax, Examples and Explanation
  • How to count keywords in a range of cell
  • How to add a line break with a formula while joining text strings in Excel
  • DOLLAR function: Description, Usage, Syntax, Examples and Explanation
  • Get first name from full name — Manipulating NAMES in Excel
  • Calculate date overlap in days in Excel
  • Excel Date & Time Functions Example
  • Get project midpoint in Excel
  • DAYS function: Description, Usage, Syntax, Examples and Explanation
  • Add decimal hours to time in Excel
  • RATE function: Description, Usage, Syntax, Examples and Explanation
  • Calculate payment periods for loan in Excel
  • COUPNUM function: Description, Usage, Syntax, Examples and Explanation
  • TBILLEQ function: Description, Usage, Syntax, Examples and Explanation
  • Calculate original loan amount in Excel
Acronyms, Abbreviations, Initialism & What They Stand For
© 2021 xlsoffice. All Rights Reserved | Teal Smiles