How to Move New Lines in a Cell to Columns in Google Sheets

This tutorial explains how to move new lines in a cell to columns or rows in Google Sheets. Before that, let’s understand what a new line is and how to add or remove them.

Introduction: Understanding New Lines

Text wrapping and new lines are two different ways of formatting text in Google Sheets. One advantage of using new lines instead of text wrapping is that you can move new lines in a cell to columns using a formula.

Text Wrapping is a built-in feature that allows users to wrap text within a cell, preventing it from overflowing into adjacent cells.

Text wrapping vs. new lines in Google Sheets

How to Add New Lines in Google Sheets

If you want to insert a new line within a cell, double-click the cell, place the cursor at the desired position, then press:

  • Windows: Alt + Enter
  • Mac: Option + Enter

How to Remove New Lines in Google Sheets

To remove new lines from a cell, use the CLEAN function, not the TRIM function.

=CLEAN(D2)
Remove new lines in Google Sheets using the CLEAN function

If the new lines were inserted without spaces, the output may look cluttered. To make the text more readable, replace new line characters with spaces using the SUBSTITUTE function:

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

This replaces each new line character (represented by CHAR(10)) with a space.

Moving New Lines to Columns or Rows in Google Sheets

Google Sheets provides a “Split text to columns” option under the Data menu, but it doesn’t support new lines (CHAR(10)) as a delimiter. Since there’s no built-in way to split text by new lines using that method, we must use formulas instead.

To move new lines to columns, use the SPLIT function:

=SPLIT(D2, CHAR(10))

If you want to move new lines to rows, combine TOCOL with SPLIT:

=TOCOL(SPLIT(D2, CHAR(10)))

These formulas allow you to restructure data by breaking multi-line values into separate columns or rows.

Moving New Lines to Columns While Keeping Groups

Sometimes, new lines within a cell are used to separate groups of data with an empty line in between. If you want to preserve these groups while moving new lines to columns, use the following formula:

=ArrayFormula(TRANSPOSE(SPLIT(TRANSPOSE(SPLIT(SUBSTITUTE(SUBSTITUTE(B4, CHAR(10)&CHAR(10), "|"), CHAR(10), "^"), "|")), "^")))
Example of moving new lines in a cell to columns while preserving groups in Google Sheets

How This Formula Works

  1. Replace Double New Lines
    The formula first replaces consecutive new lines (empty lines) with a pipe (|) symbol.
    =SUBSTITUTE(B4, CHAR(10)&CHAR(10), "|")
  2. Replace Single New Lines
    Next, it replaces single new lines with a caret (^).
    =SUBSTITUTE(SUBSTITUTE(B4, CHAR(10)&CHAR(10), "|"), CHAR(10), "^")
  3. Split and Transpose
    The formula then splits the text at each pipe (|) symbol and transposes the results.
    =TRANSPOSE(SPLIT(SUBSTITUTE(SUBSTITUTE(B4, CHAR(10)&CHAR(10), "|"), CHAR(10), "^"), "|"))
  4. Final Split & Transpose
    Finally, it splits the text at each caret (^) symbol and transposes it again, converting new lines into separate columns while preserving groups.

Conclusion

This tutorial covered how to move new lines in a cell to columns and rows using Google Sheets formulas. We also explored handling grouped data while moving new lines.

If you found this guide helpful, please share it. Thanks for reading!

Resources:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

Sort Column by Length of Text in Google Sheets

To sort a column by length of text, you can either use the QUERY...

Dynamic Way to Insert Blank Rows in a Table in Excel

Do you want to easily insert n number of blank rows in a table...

More like this

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

Sort Column by Length of Text in Google Sheets

To sort a column by length of text, you can either use the QUERY...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.