# How to add headers to a FILTER result in Excel

Stack the header row on top with VSTACK: `=VSTACK(A1:C1,FILTER(A2:C10,B2:B10=F1))`.

**Excel:** `=VSTACK(A1:C1,FILTER(A2:C10,B2:B10=F1))` (Excel 2024 and Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Item | Category | In stock |  | Category | Paper |
| Copy paper | Paper | 42 |  |  |  |
| Stapler | Desk | 15 |  |  |  |
| Sticky notes | Paper | 120 |  |  |  |
| Toner | Printing | 6 |  |  |  |
| Binders | Filing | 38 |  |  |  |
| Envelopes | Paper | 250 |  |  |  |
| Folders | Filing | 90 |  |  |  |
| Ink | Printing | 11 |  |  |  |
| Notebooks | Paper | 64 |  |  |  |

Formula in E3: `=VSTACK(A1:C1,FILTER(A2:C10,B2:B10=F1))`

Result (spills 5 × 3): Item, Category, In stock; Copy paper, Paper, 42; Sticky notes, Paper, 120; Envelopes, Paper, 250; Notebooks, Paper, 64

## How it works

FILTER returns only data rows. VSTACK puts the header row from `A1:C1` on top of them, so the result is a complete table from one formula. Because the header comes from the source, renaming a column there renames it in the result too.

## Other ways

- `=VSTACK({"Item","Stock"},FILTER(CHOOSECOLS(A2:C10,1,3),B2:B10=F1))`: Type your own headers in an array constant when the result has different columns. (Two columns, headed Item and Stock.)
- `=QUERY(A1:C10,"select * where B = '"&F1&"'",1)`: In Google Sheets, QUERY with 1 header row returns the header with the results.

## Common mistakes

- The header must have as many columns as the FILTER result. A shorter header gets padded with #N/A.
- Without a fallback, no matches makes the whole stack an error. Give FILTER a third argument: `FILTER(A2:C10,B2:B10=F1,"None")`.

## Questions

**Can I sort the rows and keep the header on top?**

Sort inside the VSTACK, not outside it: `=VSTACK(A1:C1,SORT(FILTER(A2:C10,B2:B10=F1),3,-1))`.

**How do I add a total row at the bottom?**

Stack one more row: `=LET(f,FILTER(A2:C10,B2:B10=F1),VSTACK(A1:C1,f,HSTACK("Total","",SUM(CHOOSECOLS(f,3)))))`.

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/add-headers-to-a-filter-result
