Skip to content
Back to all articles

How to break a formula into multiple lines in Google Sheets

By Yurii Vasyliev6 min read
A long ribbon folded into neat layers, standing for a formula broken across several lines

Learning how to break a formula into multiple lines in Google Sheets takes one keyboard shortcut. Sheets ignores extra spaces and line breaks outside quoted text, so you can lay a formula out however you like. The result stays the same, but a long nested formula becomes something you can read and debug. Before you start, check which kind of break you want, because people use this phrase for three different jobs.

Add a line break in the formula bar

Click the cell, then click inside the formula bar. Put the cursor where you want the break and press Ctrl+Enter on Windows or Cmd+Enter on a Mac. Plain Enter does not work here, because it saves the formula and leaves edit mode. If the bar still shows one line, drag its expand arrow so the new lines appear. Your setup may differ, so you can confirm the shortcut under Help, then Keyboard shortcuts. Excel users get the same result with Alt+Enter.

A worked example with indentation

Take a pricing formula that looks up a unit price, multiplies by quantity, adds tax, and catches errors. On one line it reads =IFERROR(VLOOKUP(A2,Prices!A:B,2,FALSE)B2(1+TaxRate),"Check item code"). That is short enough to survive, but add two more conditions and it stops being readable. To break your formula into multiple lines in Google Sheets, split it after each top-level argument and indent whatever sits inside a function.

Stepped wooden blocks showing indentation, for how to break a formula into multiple lines in Google Sheets
Each level of nesting steps in one notch, which is how indentation keeps a long formula readable.
Line in the formula barWhat it does
=IFERROR(Opens the wrapper that catches errors
  VLOOKUP(A2,Prices!A:B,2,FALSE)B2(1+TaxRate),Finds the price, then multiplies by quantity and tax
  "Check item code"Shows this message if the lookup fails
)Closes IFERROR

Three habits make this layout work. Break after commas, never in the middle of a function name. Indent one step for each level of nesting. Then put each closing bracket on its own line, lined up with the function it closes, so a missing bracket shows up at a glance.

Mistakes that break the formula

Most problems come from three slips, and each one is easy to avoid once you know it.

  • Pressing Enter on its own. It saves a half-finished formula, so you may land on an error. Use Ctrl+Enter or Cmd+Enter instead.
  • Breaking a line inside quote marks. The line break becomes part of the text, so the output changes.
  • Deleting a bracket while tidying. Count openers and closers before you save, and if an error appears, this guide to fixing Google Sheets errors helps you read it.

Shorten the formula as well as stretching it

Once you know how to break a formula into multiple lines in Google Sheets, the next question is whether it should be that long. Line breaks fix the layout, not the logic. The LET function stores an intermediate result once, so the example becomes =LET(price,VLOOKUP(A2,Prices!A:B,2,FALSE),IFERROR(priceB2(1+TaxRate),"Check item code")). A named range such as TaxRate keeps one value in one place, and a helper column lets you check each step in plain sight.

You can also leave notes inside a formula. Wrapping text in N() returns zero, so +N("includes tax") adds nothing to a sum but tells the next reader what that term does. Keep these notes short, because each one makes the formula longer.

Here is where the manual approach stops scaling. Indentation habits differ from person to person, notes live inside single cells, and nobody sees the full logic without clicking in. When several people maintain one workbook, a multi-line editor with syntax highlighting helps. Formula Foundry offers one, and you can try it in its formula creator before pasting the result into your sheet.

Three things people mean by breaking a formula

A thread in the Google Docs Editors Help Community shows the confusion well. A helper asked whether the poster wanted the formula split across lines for readability or the results split across rows. That is why a search for how to break a formula into multiple lines in Google Sheets can lead to answers about SPLIT or CHAR(10). The first meaning is layout, which you now have. The other two concern output.

Put a line break inside the result

To show two values on separate lines in one cell, join them with CHAR(10), for example =A2&CHAR(10)&B2. Then turn on text wrapping for the cell, or the break will not show. CHAR(10) is the line feed character, so it is part of the cell's value and not just its formatting. Formula Foundry's overview of text functions covers related tools for joining and cleaning text.

Split a cell's lines into separate rows

The reverse job starts with a cell that already holds several lines. =SPLIT(D2,CHAR(10)) puts each line in its own cell across a row. To make the lines run down a column instead, use =ARRAYFORMULA(TRANSPOSE(SPLIT(D2,CHAR(10)))), which is the fix a helper gave one poster in the community. For several columns at once, this community thread on splitting multiple lines in one cell into new rows combines SPLIT, FLATTEN and QUERY. The poster later needed an extra SPLIT argument because some cells held fewer lines than others.

Mind SPLIT's arguments, too. According to Ben Collins' guide to the SPLIT function, it splits on each character of the delimiter by default, and a fourth argument decides whether empty results are removed. SPLIT also needs free cells to spill into. If something blocks the way, you get a #REF! error rather than overwritten data.

Stack ranges from different sheets

Curly braces build an array, and a semicolon stacks ranges vertically while a comma places them side by side. For example, ={'Sheet 1'!A2:C;'Sheet 2'!A2:C} stacks two sheets into one block. The community thread notes that the correct separators depend on your spreadsheet's locale, so if the formula errors, check File, then Settings. Two lookalike features also cause trouble.

Data, then Split text to columns, separates text but overwrites existing data when the results overlap, as Ben Collins points out. Meanwhile, Google's Apps Script Class Range reference describes a method that breaks multi-column cells back into individual cells. That concerns merged cells, not formulas. The same page also documents reading the formulas in a range, which helps when you want to review many sheets in bulk.

Action steps

  1. Open the formula bar: Select the cell with the long formula and click inside the formula bar, then expand it so several lines show.
  2. Insert the breaks: Place the cursor after each top-level comma and press Ctrl+Enter on Windows or Cmd+Enter on a Mac.
  3. Indent and align: Indent each level of nesting and put every closing bracket on its own line, lined up with its function.
  4. Name repeated parts: Move repeated values into a named range or LET variable so the formula gets shorter, not just taller.
  5. Confirm the result: Press Enter to save and check that the cell shows the same value as before you reformatted it.

Frequently asked questions

Does a line break change what a Google Sheets formula returns?

No, as long as the break sits outside quoted text. Sheets ignores extra spaces and line breaks between parts of a formula. A break inside quote marks becomes part of the text and changes the output.

Why does Enter not add a new line in the formula bar?

Enter saves the formula and ends editing. Use Ctrl+Enter on Windows or Cmd+Enter on a Mac to add a line break while you keep editing, and check Help, then Keyboard shortcuts, if your setup differs.

How do I show a line break in the result of a formula?

Join your values with CHAR(10), such as =A2&CHAR(10)&B2, and turn on text wrapping for the cell. Without wrapping, the break does not display.

Can I add comments inside a Google Sheets formula?

Sheets has no comment syntax for formulas, but wrapping text in N() returns zero. Adding +N("your note") leaves the result unchanged and gives the next reader a short explanation.

How do I split a cell with several lines into separate rows?

Use SPLIT with CHAR(10) as the delimiter, then wrap it in ARRAYFORMULA and TRANSPOSE to make the pieces run down a column: =ARRAYFORMULA(TRANSPOSE(SPLIT(D2,CHAR(10)))).

Share this article