Google Sheets function · Google-only
ARRAYFORMULA in Google Sheets: syntax and examples
ARRAYFORMULA makes a formula work on whole ranges instead of single cells. One formula in one cell then fills a column or block with results. Functions such as SUM or IF behave differently inside it, so test the output on a few rows.
Syntax
ARRAYFORMULA(array_formula)
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
array_formula | any | yes | The formula to apply to whole ranges. Operators and most functions then work row by row. |
Examples
The examples use this table, starting in A1:
| Item | Qty | Price |
| Pen | 10 | 2.5 |
| Pad | 4 | 12 |
| Ink | 2 | 30 |
| Tape | 6 | 4 |
=ARRAYFORMULA(B2:B5*C2:C5)Result:
| 25 |
| 48 |
| 60 |
| 24 |
Line total for every row from one formula in one cell.
Run in a Google Sheet (English US locale) on .
=SUM(ARRAYFORMULA(B2:B5*C2:C5))Result: 157
The grand total of quantity times price, without a helper column.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(IF(B2:B5>5, "bulk", "single"))Result:
| bulk |
| single |
| single |
| bulk |
IF runs once per row and labels each quantity.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(UPPER(A2:A5)&"-"&B2:B5)Result:
| PEN-10 |
| PAD-4 |
| INK-2 |
| TAPE-6 |
Text functions and the & operator work over a column too.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(ROUND(C2:C5*1.19, 1))Result:
| 3 |
| 14.3 |
| 35.7 |
| 4.8 |
Price with a 19% markup, rounded to one decimal.
Run in a Google Sheet (English US locale) on .
Common errors
- A range inside a normal formula does not multiply cell by cell. =B2:B5*C2:C5 returns #VALUE!, and wrapping it in ARRAYFORMULA fixes that.
- SUM and AVERAGE need the array operation wrapped too. =SUM(B2:B5*C2:C5) and =AVERAGE(B2:B5*C2:C5) return #VALUE! until ARRAYFORMULA surrounds the product.
- Ranges of different height do not raise an error for the whole formula. The extra rows get #N/A, so a size mismatch hides in the last row.
- The result needs empty cells below and to the right. If something sits in the way, the spill stops and the cell shows #REF!.
Compared with Excel
Excel 365 spills results on its own, so a plain formula over ranges already works there. Older Excel needed Ctrl+Shift+Enter for the same effect.
Questions and answers
Do I still need ARRAYFORMULA for IF, UPPER or VLOOKUP over a range?
Yes. Without it, IF(B2:B5>5, ...), UPPER(A2:A5) and VLOOKUP with a range as key return #VALUE!. ARRAYFORMULA makes them run once per row.