Spreadsheet Practice

How to put a header and ARRAYFORMULA in the same cell in Google Sheets

Google Sheets formula

={"Pay";ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C))}

Stack the header text on top of the results with an array: ={"Pay";ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C))} in the header cell.

Result on the example
a 46-row list that spills from D1 in D1
Excel
See below

See it work

The formula is already in D1. Change any input and the result updates, or edit the formula to experiment.

How it works

In an array, a semicolon starts a new row, so {"Pay";…} puts the text in D1 and the calculated column directly under it. Keeping the formula in the header row protects it: sorting the data or inserting rows can't move it, and nobody types over it by accident.

={"Pay";ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C))}

Result{46 rows × 1 col} "Pay", 931, 880, 845, …

  1. A2:A45 rows × 1 col: "Ana Ruiz", "Raj Patel", "Lee Chen", "Kim Ortiz", …

    A range: 45 cells in one column.

  2. A2:A=""{45 rows × 1 col} FALSE, FALSE, FALSE, FALSE, …

    The = operator tests whether the two sides are equal.

  3. B2:B45 rows × 1 col: 38, 40, 32.5, 40, …

    A range: 45 cells in one column.

  4. C2:C45 rows × 1 col: $24.50, $22.00, $26.00, $21.75, …

    A range: 45 cells in one column.

  5. B2:B*C2:C{45 rows × 1 col} 931, 880, 845, 870, …

    The * operator multiplies.

  6. IF(A2:A="","",B2:B*C2:C){45 rows × 1 col} 931, 880, 845, 870, …

    IF: Returns one value if a test is true, another if false.

    • logical_testA2:A=""{45 rows × 1 col} FALSE, FALSE, FALSE, FALSE, …
    • value_if_true""
    • value_if_falseB2:B*C2:C{45 rows × 1 col} 931, 880, 845, 870, …
  7. ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C)){45 rows × 1 col} 931, 880, 845, 870, …

    ARRAYFORMULA: Runs a formula over whole ranges and returns all the results.

    • array_formulaIF(A2:A="","",B2:B*C2:C){45 rows × 1 col} 931, 880, 845, 870, …
  8. {"Pay";ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C))}{46 rows × 1 col} "Pay", 931, 880, 845, …

    An array of values.

In Excel

In Excel, use VSTACK to put a header on a spilled result: =VSTACK("Pay",B2:B6*C2:C6). A Table (Ctrl+T) is the usual way to keep a calculated column in step with new rows.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=VSTACK("Pay",ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C)))spills 46 × 1VSTACK does the same stacking and reads more clearly.

Common mistakes

  • A comma instead of the semicolon puts "Pay" beside the results instead of above them, in most locales.
  • Sorting with Data > Sort range must start at row 2; the formula in row 1 keeps its place either way.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Put a header and ARRAYFORMULA in the same cell

In the header cell D1, write one formula that shows the header "Pay" and, below it, Hours times Rate for every employee, including rows added later.

Questions

Why not put the formula in D2?

Row 2 moves when you sort or insert rows above it. Row 1 never does, so the formula stays safe.

Can I do this with QUERY or FILTER?

Those can return their own header. FILTER can't, so stack one: ={"Name";FILTER(A2:A,B2:B>35)}.

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine.