Sheet Clinic

ARRAYFORMULA down a whole column, stopping at the last row

One ARRAYFORMULA in the top row can fill a whole column. Clear the old copies under it and wrap the math in IF so it stops at the last row.

Sheet Clinic editorsPublished
E2=ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35))

Before =ARRAYFORMULA(C2:C*15+D2:D*35)

BCDE
1NameT-shirtsHoodiesTotal ($)
2Emily21#REF!
3Jacob1015
4Sarah0270
5Michael3180
6Ashley1150
7David20 

What changed

  1. E3:E cleared
  2. IF(A2:A="", , ...) added around the math

After one formula in E2

BCDE
1NameT-shirtsHoodiesTotal ($)
2Emily2165
3Jacob1015
4Sarah0270
5Michael3180
6Ashley1150
7David2030
Figure 1. Column E of the order sheet. Before, hand-copied formulas sit under the ARRAYFORMULA and David has no total. After, E2 alone fills E2:E7 and leaves the empty rows below alone.

On the Fixed tab, column E holds one formula, in E2, and it fills in a total for every order: 65, 15, 70, 80, 50 and 30 for Emily through David, then nothing below the last order. Here it is:

=ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35))

ARRAYFORMULA is what lets one cell do a whole column. Write the row math once with open ranges in place of single cells, so C2 becomes C2:C, and put an IF around it that asks whether a column every real row fills in is empty. Where it is empty the row gets nothing, which is how the results stop at the last row. Anything already sitting below the formula has to be cleared first, or the formula cell shows #REF! and nothing fills in.

The sheet is laid out like a form response tab. Column A has a timestamp, B a name, C and D how many T-shirts and hoodies each person ordered, and E the total in dollars at $15 a shirt and $35 a hoodie.

The Broken tab shows how the column looked before that formula. Someone wrote =C3*15+D3*35 and dragged it down to row 6. David's order then arrived in row 7, and E7 stayed empty, because a copied formula only exists in the rows it was copied to. Typing =ARRAYFORMULA(C2:C*15+D2:D*35) into E2 was the right idea, and it still produced #REF! with a red note: Array result was not expanded because it would overwrite data in E3.

Clear the hand-copied formulas below ARRAYFORMULA, or it shows #REF!

ARRAYFORMULA in E2 wants to write one answer per row, from E2 down. The old formulas still occupy E3:E6. The note names E3 because that is the first cell in the way. Jacob's 15, Sarah's 70, Michael's 80 and Ashley's 50 are all correct numbers, so nothing on screen marks them as leftovers.

Google Sheets, Broken tab, E2 selected. The formula bar shows =ARRAYFORMULA(C2:C*15+D2:D*35). E2 shows #REF! and the note reads: Array result was not expanded because it would overwrite data in E3. E3:E6 show 15, 70, 80 and 50, and E7 is empty.
Figure 2. The Broken tab. Selecting E2 with the Name box brings up the note.

Type E3:E into the Name box (the address field left of the formula bar), press Enter, then press Delete, and leave E2 in place. Anything typed under the formula later brings the error back, so a grand total such as =SUM(E2:E) has to sit in some other column. Other things that block an array result, including cells that only look empty, are in "Array result was not expanded" in Google Sheets: what's in the way. On the Fixed tab that one step plus the change in the next section gives 65, 15, 70, 80, 50, 30 for Emily through David, including the 30 that David never had.

Google's ARRAYFORMULA page also lists a shortcut. Pressing Ctrl+Shift+Enter while editing a formula adds ARRAYFORMULA( to the front of it, so you can write the plain version first and wrap it at the end.

Without an IF test, ARRAYFORMULA fills every empty row with 0

Once E3:E is clear, the plain =ARRAYFORMULA(C2:C*15+D2:D*35) does expand. It also keeps going. The More causes tab runs that version in column E, and every row past David shows 0, because an empty C times 15 plus an empty D times 35 is 0. Two checks on the same tab put a number on it. =COUNTIF(E2:E, 0) returned 993, and =COUNTA(E2:E) returned 999. The same COUNTA on the Fixed tab returned 6, one per order.

More causes tab, E2 selected, formula bar =ARRAYFORMULA(C2:C*15+D2:D*35). E2:E7 show 65, 15, 70, 80, 50, 30 and E8 onward show 0. Column K shows 993, 999 and 6.
Figure 3. The More causes tab. Column E has no stop, so the zeros start in E8.

The formula fills the column, and COUNTA reports 999 entries for six orders. What it needs is a test that leaves a row blank when there is no order in it:

=ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35))

A2:A="" checks every timestamp. Where it is empty, IF returns its second argument, and since nothing is typed between the two commas, that argument is an empty cell rather than 0 or a blank string. Where there is a timestamp, the math runs. Column A works as the test here because every order row has a timestamp. On a sheet people type into by hand, test a column nobody skips, such as the name, by changing A2:A to that column's range.

Fixed tab, E2 selected. The formula bar shows =ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35)). E2:E7 show 65, 15, 70, 80, 50, 30 and E8 down is empty.
Figure 4. The Fixed tab. The totals end at row 7 with David's 30.

SUM inside ARRAYFORMULA repeats one total on every row: use + or BYROW

A second column on the More causes tab counts items per order. The first attempt was =ARRAYFORMULA(IF(A2:A="", , SUM(C2:C, D2:D))), and every order row came back as 14. That number is all the T-shirts plus all the hoodies in the sheet. SUM takes the whole ranges it is given and returns one number, and ARRAYFORMULA cannot turn that back into one result per row.

More causes tab, F2 selected, formula bar =ARRAYFORMULA(IF(A2:A="", , SUM(C2:C, D2:D))). F2:F7 all show 14. G2:G7 and H2:H7 show 3, 1, 2, 4, 2, 2.
Figure 5. Column F repeats 14 on each order row. Columns G and H give the per-row counts.

Two formulas on the same tab give the per-row answer. Column H uses plain addition, =ARRAYFORMULA(IF(A2:A="", , C2:C+D2:D)), which works row by row the same way the multiplication in the total does. It returned 3, 1, 2, 4, 2 and 2. Addition is the simpler choice when there are only a couple of columns.

Column G uses =BYROW(C2:D, LAMBDA(r, IF(COUNT(r)=0, , SUM(r)))). BYROW hands each row of C2:D to the LAMBDA as r, so SUM sees one row at a time. Google's page says each row has to come back as a single value, which SUM does. The COUNT test plays the same role as the timestamp test in E2. Rows with no numbers stay blank instead of showing 0. Column G matched column H on all six orders. BYROW does not need ARRAYFORMULA around it, since it already returns one value per row.

AND behaves like SUM inside ARRAYFORMULA and returns one value for the whole range. For a TRUE or FALSE on each row, or a running total down the column, MAP and SCAN do the job, in MAP, REDUCE and SCAN in Google Sheets on real data.

Practicing both steps on the Try it yourself tab

The Try it yourself tab is the broken version again, old formulas and all. Select E3:E through the Name box and press Delete, then replace E2 with =ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35)). E2:E7 should then read 65, 15, 70, 80, 50 and 30, the same as the Fixed tab.

Input6 orders in A2:D7, prices $15 and $35
Formula=ARRAYFORMULA(IF(A2:A="", , C2:C*15+D2:D*35))
Expected65, 15, 70, 80, 50, 30
Sheets returned65, 15, 70, 80, 50, 30 Matches expected
Checked2026-11-11, free personal account

Take-home copy. Four tabs: Broken (as you see it), Fixed, Try it yourself, More causes. It opens as a copy in your own Drive.

Copy the sheet