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

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.

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

**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.

## Example

Sample data (row 1 is the header):

| A | B | C |
| --- | --- | --- |
| Employee | Hours | Rate |
| Ana Ruiz | 38 | 24.5 |
| Raj Patel | 40 | 22 |
| Lee Chen | 32.5 | 26 |
| Kim Ortiz | 40 | 21.75 |
| Mo Diaz | 36 | 23 |

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

Result (spills 46 × 1): Pay; $931.00; $880.00; $845.00; $870.00; $828.00; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; 

## 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.

## Other ways

- `=VSTACK("Pay",ARRAYFORMULA(IF(A2:A="","",B2:B*C2:C)))`: VSTACK 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.

## 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)}`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/put-a-header-and-arrayformula-in-one-cell
