How to Go to the Next Line in Google Sheets (Line Break)

- Written by Puneet

Let’s say in Google Sheets, you want to track some addresses and you want to add the entire address in the same cell, like the below:

go-to-next-line-in-google-sheets

This can be done when you use a line break to enter a new line within the same cell. Just like Excel, you can add a line break in Google Sheets, and in this tutorial, we will learn different ways to do this.

What is a Line Break?

A line break in Google Sheets allows you to start a new line within the same cell. Line breaks are super helpful when organizing information neatly within a single cell. If entering an address, you can have the street, apartment number, and city on separate lines within one cell. This keeps your data clean and easy to read, making it look more professional and organized.

Use a Keyboard Shortcut to Add a Line Break

To add a line break using a keyboard shortcut, follow these simple steps:

  • Click on the cell where you want to enter your text and start typing the first line.
  • Press Alt + Enter (on Windows) or Ctrl + Enter (on Mac) to move the cursor to a new line within the same cell.
shortcut-to-add-line-break

Type the following line of your text. Repeat the line break shortcut to add more lines as needed.

Using CHAR Function to Add Line Breaks

CHAR function is used to return the character specified by a number. Using an ASCII code for line breaks, you can insert a new line within a cell using the CHAR function.

char-function-to-add-line-breaks

Using CHAR(10) is helpful when adding line breaks in text, especially when combining multiple pieces of text or when generating text dynamically through formulas.

In the same way, you can create a better formula with the help of TEXTJOIN to combine values from multiple cells to create multiple lines within the same and add a line break in between.

combine-textjoin-and-char-functions

In this formula, TEXTJOIN is a function that joins text from multiple cells into one cell. The CHAR(10) part tells the formula to use a line break as the separator between the texts. The TRUE argument means it will ignore any empty cells. Finally, A1:B1 specifies the range of cells whose text you want to join.

Tip: When using a formula to add a line break and encountering a problem, apply wrap text to the cell.

Use Google App Script to Add a Line Break

If you need to apply a line break to multiple cell values and want to combine them in a single cell, you can use a custom function with Google App Script.

google-app-script-to-add-line-break
/**
 * Custom function to combine cell values with line breaks, ignoring empty cells.
 *
 * @param {Range} range The range of cells to combine.
 * @return {String} The combined text with line breaks.
 * @customfunction
 */
function COMBINEWITHLINEBREAK(range) {
  if (!(range instanceof Array)) {
    throw new Error('Invalid input: Please provide a valid range.');
  }

  // Flatten the range to a single array of values
  var values = range.flat();

  // Combine the cell values with a line break, ignoring empty cells
  var combinedText = values.filter(function(value) {
    return value !== '';
  }).join('\n');
  
  return combinedText;
}

To use this script, go to the Extensions > Apps Script. Paste the code, and click the disk icon to save your script.