Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Subtotal function in Excel
  • How to combine 2 or more chart types in a single chart in Excel
  • Calculate Conditional Percentile ‘IF’ in table in Excel
  • How To Insert and Customize Sparklines in Excel
  • Conditional Formatting Data bars Examples in Excel

References

  • INDEX function: Description, Usage, Syntax, Examples and Explanation
  • Get nth match with INDEX / MATCH in Excel
  • LOOKUP function: Description, Usage, Syntax, Examples and Explanation
  • Two-column Lookup in Excel
  • Convert text string to valid reference in Excel using Indirect function

Data Validations

  • Excel Data validation specific characters only
  • Excel Data validation must contain specific text
  • Excel Data validation allow weekday only
  • Excel Data validation whole percentage only
  • Excel Data validation allow uppercase only

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:   How to extract multiple lines from a cell in Excel

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

Worked Example:   Get position of 2nd 3rd and more instance of character 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:   Join cells with comma 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

Logical Functions

  • AND function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel OR Function
  • IF with boolean logic in Excel
  • Complete List of Excel Logical Functions, References and Examples
  • IF, AND, OR and NOT Functions Examples in Excel

Date Time

  • Add decimal minutes to time in Excel
  • Add years to date in Excel
  • Calculate expiration date in Excel
  • Count holidays between two dates in Excel
  • How to Calculate Age in Excel

Grouping

  • Group times into unequal buckets in Excel
  • Map inputs to arbitrary values in Excel
  • Calculate conditional mode with criteria in Excel
  • How to randomly assign data to groups in Excel
  • Group arbitrary text values in Excel

General

  • 231 Keyboard Shortcut Keys In Excel
  • Convert column letter to number in Excel
  • Check if range contains a value not in another range in Excel
  • Spell Check in Excel
  • Hide and Unhide Columns or Rows in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning