Multiple Column Values in a Single Cell as New Lines in Google Sheets

Published on

This tutorial is not about combining values across multiple columns but rather about placing multiple column values into a single cell as new lines in Google Sheets.

When could this be useful in real life?

Suppose you have a spreadsheet where employee addresses are entered in multiple columns, like this:

Table # 1:

NameAddressPhone #Email
Rose321 Maple St, Apt 11(555) 123-4567rose.123@example.com

You may want to combine these column values into a single cell with each value on a new line for printing labels or other purposes.

Table # 2:

Rose
321 Maple St, Apt 11
(555) 123-4567
rose.123@example.com

In such cases, instead of manually copying and pasting, which is time-consuming, you can use the following formula to automate the process.

Multiple Columns into a Multi-Line Single Cell: Non-Array Formula

My sample data spans across A1:D, with A1:D1 containing the column names Name, Address, Phone #, and Email.

Multiple Columns Combined into a Single Cell with Multi-Line Formatting

To combine the information from multiple columns into a single cell with each value on a new line, you can use the TEXTJOIN function as follows:

In cell F2, enter the following formula and drag it down as needed:

=TEXTJOIN(CHAR(10), TRUE, A2:D2)

Explanation:

  • TEXTJOIN(delimiter, ignore_empty, text1, [text2, …])
    • delimiter (the separator between each cell value) is CHAR(10), which represents a new line character.
    • ignore_empty is set to TRUE, which removes empty cells while combining.
    • text1 is the range A2:D2.

This formula combines the values in A2:D2 into a single cell with each value on a new line. When you drag the formula down, it applies to the data in the corresponding rows.

Multiple Columns into a Multi-Line Single Cell: Array Formula

If you prefer using Array Formulas, you might have tried the following formulas in cell F2:

=TEXTJOIN(CHAR(10), TRUE, A2:D)

And:

=ArrayFormula(TEXTJOIN(CHAR(10), TRUE, A2:D))

Unfortunately, both formulas will return the same result and might not meet your needs.

To handle multiple column values in a single cell across multiple rows, use the following array formula in cell F1:

=ArrayFormula(
   TRIM(
      TRANSPOSE(
         SPLIT(
            TEXTJOIN(CHAR(10), TRUE, {"~"&A2:A, B2:D}), "~"
         )
      )
   )
)

Explanation:

  • TEXTJOIN(CHAR(10), TRUE, {"~"&A2:A, B2:D}) combines the values from multiple columns into a single text string, with each value separated by a new line (CHAR(10)), and adds a ~ before the values in the first column.
  • To test this, use a closed range and include the ARRAYFORMULA as follows: =ArrayFormula(TEXTJOIN(CHAR(10), TRUE, {"~"&A2:A4, B2:D4}))

Result:

~Rose
321 Maple St, Apt 11
(555) 123-4567
rose.123@example.com
~Mike
654 Oak St
(555) 234-5678
mike_ny@example.com
~Lisa
987 Pine St, Suite 1
(555) 345-6789
lisa.carol@example.com
  • SPLIT(…, "~") splits the combined text string based on the ~ delimiter, placing each address across the row.
Rose
321 Maple St, Apt 11
(555) 123-4567
rose.123@example.com
Mike
654 Oak St
(555) 234-5678
mike_ny@example.com
Lisa
987 Pine St, Suite 1
(555) 345-6789
lisa.carol@example.com
  • TRANSPOSE(…) arranges the split results into a vertical format.
  • The TRIM function removes any extra blank lines introduced during the process.

Lambda Approach

You can use the BYROW lambda function to simplify the drag-down TEXTJOIN formula.

Instead of using the regular array formula, you can use the following BYROW formula in cell F2 to combine multiple column values into a single cell in Google Sheets:

=BYROW(A2:D, LAMBDA(row, TEXTJOIN(CHAR(10), TRUE, row)))

Explanation:

  • The BYROW formula processes each row in the array A2:D and applies the TEXTJOIN function to combine the values in that row into a single cell, separated by newlines (CHAR(10)).
  • The row in the LAMBDA function represents each row of data from the array A2:D.

You can use any of the above formulas to combine multiple column values into a single cell. However, I recommend avoiding the LAMBDA approach if you have a large dataset, as it may impact performance.

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.

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

Excel: How to Insert Subtotals Using a Dynamic Array Formula

You can easily insert subtotals using a dynamic array formula in Excel. Why use...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

6 COMMENTS

  1. Prashanth, Excellent contribution. An error appears.

    “Error In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.”

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.